tjc-sdk
Version:
TIANJI IM SDK
2 lines (1 loc) • 854 B
JavaScript
import t from"./messageContent.js";import{MessageContentType as e}from"./messageContentType.js";import s from"../client/tjc.js";import o from"../model/quoteInfo.js";class r extends t{content;quoteInfo;constructor(t,s=0,o=[]){super(e.Text,s,o),this.content=t}digest(){return this.content}encode(){let t=super.encode();if(t.searchableContent=this.content,this.quoteInfo){let e={quote:this.quoteInfo.encode()},o=JSON.stringify(e).replace(/"u":"([0-9]+)"/,'"u":$1');t.binaryContent=s.utf8_to_b64(o)}return t}decode(t){if(super.decode(t),this.content=t.searchableContent,t.binaryContent&&t.binaryContent.length>0){let e=s.b64_to_utf8(t.binaryContent);e=e.substring(0,e.lastIndexOf("}")+1),e=e.replace(/"u":([0-9]+),/,'"u":"$1",');let r=JSON.parse(e).quote;this.quoteInfo=new o,this.quoteInfo.decode(r)}}setQuoteInfo(t){this.quoteInfo=t}}export{r as default};