tjc-sdk
Version:
TIANJI IM SDK
2 lines (1 loc) • 985 B
JavaScript
import t from"./messageContent.js";import{MessageContentType as s}from"./messageContentType.js";import e from"../client/tjc.js";import i from"../config.js";class r extends t{cardType=0;target;name;displayName;portrait;from;constructor(t,e,i,r,h){super(s.UserCard),this.cardType=t,this.target=e,this.displayName=i,this.portrait=r,this.from=h}encode(){let t=super.encode();t.content=this.target;let s={t:this.cardType,n:this.name,d:this.displayName,p:this.portrait,f:this.from};return t.binaryContent=e.utf8_to_b64(JSON.stringify(s)),t}decode(t){super.decode(t),this.target=t.content;let s=JSON.parse(e.b64_to_utf8(t.binaryContent));this.cardType=s.t,this.name=s.n,this.displayName=s.d,this.portrait=s.p,i.urlRedirect&&(this.portrait=i.urlRedirect(s.p)),this.from=s.f}digest(){let t="[名片]";switch(this.cardType){case 0:t="[个人名片]";break;case 1:t="[群组名片]";break;case 2:t="[聊天室名]";break;case 3:t="[频道名片]"}return t+this.displayName}}export{r as default};