MessageContent 类(Electron IMLib)

类继承图​

Object→MessageContent

继承关系:Object → MessageContent。该内容联合体按 type 取值不包含行为方法,字段与 domain.json → schemas.Content 一一对应。

类说明​

消息内容联合体:按 type 取不同字段,序列化后不超过 5KB;文本、图片、文件、语音、位置、自定义、撤回占位与系统通知共用该结构。

项值
类型数据结构(值对象)
字段数21
IDL 定义domain.json → schemas.Content
程序包@ni-paas-im/electron
跨端一致性字段名与取值在 7 个平台绑定中一致;仅语言类型映射不同
平台状态已交付

字段概要​

字段类型必填说明
typeContentType是类型
textstring否text:非空
urlstring否image/file/voice 必填
namestring否file
sizeuint64否字节数
mimestring否MIME 类型
widthuint32否图片宽度(px)
heightuint32否图片高度(px)
durationuint32否voice 1..300 秒
latitudedouble否location [-90,90]
longitudedouble否location [-180,180]
addressstring否location,<=200 字
dataany否custom 任意 JSON
mentionedInfoMentionedInfo否仅群聊/超级群
quoteQuote否引用消息快照
recallMessageIdstring否recall 占位
operatorIdstring否recall 操作者
systemTypeSystemType否system 消息子类型
extrastring否system 消息扩展 JSON 字符串
titlestring否combine:合并转发标题,必填、非空、<=64 字(IDL rev19)
itemsCombineItem[]否combine:合并转发条目,必填、1..=100 条、顺序即展示顺序;全部条目 text 合计 <=16KB(IDL rev19)

详细字段说明​

ContentType type
必填

类型

string text
可选

text:非空

string url
可选

image/file/voice 必填

string name
可选

file

uint64 size
可选

字节数

string mime
可选

MIME 类型

uint32 width
可选

图片宽度(px)

uint32 height
可选

图片高度(px)

uint32 duration
可选

voice 1..300 秒

double latitude
可选

location [-90,90]

double longitude
可选

location [-180,180]

string address
可选

location,<=200 字

any data
可选

custom 任意 JSON

MentionedInfo mentionedInfo
可选

仅群聊/超级群

Quote quote
可选

引用消息快照

string recallMessageId
可选

recall 占位

string operatorId
可选

recall 操作者

SystemType systemType
可选

system 消息子类型

string extra
可选

system 消息扩展 JSON 字符串

string title
可选自 1.3.0

combine:合并转发标题,必填、非空、<=64 字(IDL rev19)

CombineItem[] items
可选自 1.3.0

combine:合并转发条目,必填、1..=100 条、顺序即展示顺序;全部条目 text 合计 <=16KB(IDL rev19)

相关链接​