import type { Message } from '@tencentcloud/lite-chat/basic';
import type TencentCloudChat from '@tencentcloud/lite-chat/basic';
import type { ModifyMessageParams, ReactionInfo } from '../../type';
/**
* @description MessageModel 主要负责消息操作和消息上屏数据处理,MessageModel 不需要开发者进行开发,由 TUIChatEngine 通过 {@link https://web.sdk.qcloud.com/im/doc/chat-engine/global.html#ChatStore ChatStore} 的 messageList 提供给开发者直接使用。
* @interface IMessageModel
* @property {String} ID - 消息 ID
* @property {String} type - 消息类型,具体如下:
* | 类型 | 含义 |
* | :--- | :---- |
* | TUIChatEngine.TYPES.MSG_TEXT | 文本消息 |
* | TUIChatEngine.TYPES.MSG_IMAGE | 图片消息 |
* | TUIChatEngine.TYPES.MSG_SOUND | 音频消息 |
* | TUIChatEngine.TYPES.MSG_AUDIO | 音频消息 |
* | TUIChatEngine.TYPES.MSG_VIDEO | 视频消息 |
* | TUIChatEngine.TYPES.MSG_FILE | 文件消息 |
* | TUIChatEngine.TYPES.MSG_CUSTOM | 自定义消息 |
* | TUIChatEngine.TYPES.MSG_MERGER | 合并消息 |
* | TUIChatEngine.TYPES.MSG_LOCATION | 位置消息 |
* | TUIChatEngine.TYPES.MSG_FACE | 表情消息 |
* | TUIChatEngine.TYPES.MSG_GRP_TIP | 群提示消息 |
* | TUIChatEngine.TYPES.MSG_GRP_SYS_NOTICE | 群系统通知消息 |
* @property {Object} payload - 消息的内容,详细内容请查看: [Message](https://web.sdk.qcloud.com/im/doc/v3/zh-cn/Message.html)
* @property {String} conversationID - 消息所属的会话 ID
* @property {String} conversationType - 消息所属会话的类型,具体如下:
* | 类型 | 含义 |
* | :--- | :---- |
* | TUIChatEngine.TYPES.CONV_C2C | C2C(Client to Client, 端到端) 会话 |
* | TUIChatEngine.TYPES.CONV_GROUP | GROUP(群组) 会话 |
* | TUIChatEngine.TYPES.CONV_SYSTEM | SYSTEM(系统) 会话 |
* @property {String} to - 接收方的 userID
* @property {String} from - 发送方的 userID,在消息发送时,会默认设置为当前登录的用户
* @property {String} flow - 消息的流向
* - in 为收到的消息
* - out 为发出的消息
* @property {Number} time - 消息时间戳。单位:秒
* @property {String} status - 消息状态
* - unSend(未发送)
* - success(发送成功)
* - fail(发送失败)
* @property {Boolean} isRevoked =false - 是否被撤回的消息,true 标识被撤回的消息
* @property {String} priority=TUIChatEngineTYPES.MSG_PRIORITY_NORMAL - 消息优先级,用于群聊
* @property {String} nick='' 消息发送者的昵称(在 AVChatRoom 内支持,需提前调用 [TUIUserService.updateMyProfile](https://web.sdk.qcloud.com/im/doc/chat-engine/ITUIUserService.html#updateMyProfile) 设置)
* @property {String} avatar='' 消息发送者的头像地址(在 AVChatRoom 内支持,需提前调用 [TUIUserService.updateMyProfile](https://web.sdk.qcloud.com/im/doc/chat-engine/ITUIUserService.html#updateMyProfile) 设置)
* @property {Boolean} isPeerRead=false - C2C 消息对端是否已读,true 标识对端已读
* @property {String} nameCard='' 非直播群消息发送者的群名片(也可称之为消息发送者的群昵称),需提前调用 [TUIGroupService.setGroupMemberNameCard](https://web.sdk.qcloud.com/im/doc/chat-engine/ITUIGroupService.html#setGroupMemberNameCard) 设置
* @property {Array} atUserList 群聊时此字段存储被 at 的群成员的 userID
* @property {String} cloudCustomData='' - 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到)
* @property {Boolean} isDeleted=false - 是否被删除的消息,true 标识被删除的消息
* @property {Boolean} isModified=false - 是否被修改过,true 标识被修改过的消息
* @property {Boolean} needReadReceipt=false - 是否需要已读回执,true 标识需要(需要您购买旗舰版套餐)
* @property {Object} readReceiptInfo={readCount,unreadCount,isPeerRead} - 消息已读回执信息
* @property {Number|undefined} readReceiptInfo.readCount - 群消息已读数
* 如果想要查询哪些群成员已读了消息,可调用 [TUIChatService.getGroupMessageReadMemberList](https://web.sdk.qcloud.com/im/doc/chat-engine/ITUIChatService.html#getGroupMessageReadMemberList)
* @property {Number|undefined} readReceiptInfo.unreadCount - 群消息未读数
* @property {Boolean|undefined} readReceiptInfo.isPeerRead - C2C消息对端是否已发送已读回执,消息发送方收到已读回执通知或拉漫游时会更新此属性
* @property {Boolean} isBroadcastMessage=false - 对所有直播群广播消息,true 标识直播群广播消息(需要您购买旗舰版套餐)
* @property {Boolean} isSupportExtension=false - 是否支持消息扩展,true 支持 false 不支持(需要您购买旗舰版套餐)
* @property {String|null} revoker - 消息撤回者的 userID
* @property {Number} progress - 图片、视频、语音、文件消息上传进度, 默认 0
* @property {Object} revokerInfo - 消息撤回者的信息。
* @property {String} revokerInfo.avatar - 消息撤回者的头像
* @property {String} revokerInfo.nick - 消息撤回者的昵称
* @property {String} revokerInfo.userID - 消息撤回者的 userID
* @property {String} revokeReason - 消息撤回的原因。
* @property {Boolean} hasRiskContent - 语音、视频消息是否被标记为有安全风险的消息,默认为 false。
* - 只有在开通【云端审核】功能后才生效,【云端审核】开通流程请参考 [云端审核功能](https://cloud.tencent.com/document/product/269/83795#.E4.BA.91.E7.AB.AF.E5.AE.A1.E6.A0.B8.E5.8A.9F.E8.83.BD)。
* @property {Array} reactionList - 需要您购买旗舰版才支持此功能,购买旗舰版能力并重新登录后,拉漫游时会自动获取表情回复摘要信息。
*/
export interface IMessageModel {
ID: string;
type: TencentCloudChat.TYPES;
payload: any;
conversationID: string;
conversationType: TencentCloudChat.TYPES;
to: string;
from: string;
flow: string;
time: number;
status: string;
isRevoked: boolean;
priority: TencentCloudChat.TYPES;
nick: string;
avatar: string;
isPeerRead: boolean;
nameCard: string;
atUserList: string[];
cloudCustomData: string;
isDeleted: boolean;
isModified: boolean;
needReadReceipt: boolean;
readReceiptInfo: any;
isBroadcastMessage: boolean;
isSupportExtension: boolean;
receiverList?: string[];
revoker: string;
sequence: number;
progress: number;
revokerInfo: { userID: string; nick: string; avatar: string };
revokeReason: string;
hasRiskContent: boolean;
reactionList: ReactionInfo[];
/**
* 更新 messageModel 属性
* @function
* @private
*/
updateProperties(options: Message): void;
/**
* 获取 Chat SDK 提供的 message 实例
* @function
* @private
* @example
* let message = messageModel.getMessage();
*/
getMessage(): Message;
/**
* 修改消息
*
* @param {ModifyMessageParams} options 修改的内容
* @function
* @example
* let promise = messageModel.modifyMessage(options);
* promise.catch((error) => {
* // 调用异常时业务侧可以通过 promise.catch 捕获异常进行错误处理
* });
*/
modifyMessage(options: ModifyMessageParams): Promise;
/**
* 撤回单聊消息或者群聊消息。撤回成功后,消息对象的 isRevoked 属性值为 true。
* @function
* @example
* let promise = messageModel.revokeMessage();
* promise.catch((error) => {
* // 调用异常时业务侧可以通过 promise.catch 捕获异常进行错误处理
* });
*/
revokeMessage(): Promise;
/**
* 重发消息的接口,当消息发送失败时,可调用该接口进行重发
* @function
* @example
* let promise = messageModel.resendMessage();
* promise.catch((error) => {
* // 调用异常时业务侧可以通过 promise.catch 捕获异常进行错误处理
* });
*/
resendMessage(): Promise;
/**
* 删除消息的接口。删除成功后,被删除消息的 isDeleted 属性值为 true。
* @function
* @example
* let promise = messageModel.deleteMessage();
* promise.catch((error) => {
* // 调用异常时业务侧可以通过 promise.catch 捕获异常进行错误处理
* });
*/
deleteMessage(): Promise;
/**
* 引用当前消息
* @function
* @example
* let message = messageModel.quoteMessage();
*/
quoteMessage(): Message;
/**
* 回复当前消息
* @function
* @example
* let message = messageModel.replyMessage();
*/
replyMessage(): Message;
/**
* 设置消息扩展
* @function
* @param {Array