IMessageModel

IMessageModel

Properties:
Name Type Default Description
ID String

Message ID

type String

Message type:

Type Description
TUIChatEngine.TYPES.MSG_TEXT Text message
TUIChatEngine.TYPES.MSG_IMAGE Image message
TUIChatEngine.TYPES.MSG_SOUND Audio message
TUIChatEngine.TYPES.MSG_AUDIO Audio message
TUIChatEngine.TYPES.MSG_VIDEO Video message
TUIChatEngine.TYPES.MSG_FILE File message
TUIChatEngine.TYPES.MSG_CUSTOM Custom message
TUIChatEngine.TYPES.MSG_MERGER Merged message
TUIChatEngine.TYPES.MSG_LOCATION Location message
TUIChatEngine.TYPES.MSG_FACE Emoji message
TUIChatEngine.TYPES.MSG_GRP_TIP Group tip message
TUIChatEngine.TYPES.MSG_GRP_SYS_NOTICE Group system notice message
payload Object

Message content

conversationID String

Conversation ID the message belongs to

conversationType String

Conversation type:

Type Description
TUIChatEngine.TYPES.CONV_C2C C2C (Client to Client) conversation
TUIChatEngine.TYPES.CONV_GROUP GROUP conversation
TUIChatEngine.TYPES.CONV_SYSTEM SYSTEM conversation
to String

Recipient userID

from String

Sender userID (automatically set to current logged-in user when sending)

flow String

Message direction

  • in: received message
  • out: sent message
time Number

Message timestamp (seconds)

status String

Message status

  • unSend (not sent)
  • success (sent successfully)
  • fail (failed to send)
isRevoked Boolean false

Whether the message is revoked

priority String TUIChatEngineTYPES.MSG_PRIORITY_NORMAL

Message priority (for group chats)

nick String ''

Sender nickname (supported in AVChatRoom, requires calling TUIUserService.updateMyProfile first)

avatar String ''

Sender avatar URL (supported in AVChatRoom, requires calling TUIUserService.updateMyProfile first)

isPeerRead Boolean false

Whether peer has read C2C message

nameCard String ''

Group name card (requires calling TUIGroupService.setGroupMemberNameCard first)

atUserList Array

List of @ mentioned userIDs in group chat

cloudCustomData String ''

Custom message data (stored in cloud, sent to peer, can be retrieved after app reinstall)

isDeleted Boolean false

Whether the message is deleted

isModified Boolean false

Whether the message is modified

needReadReceipt Boolean false

Whether read receipt is needed (requires Ultimate edition)

readReceiptInfo Object {readCount,unreadCount,isPeerRead}

Read receipt info

Properties
Name Type Description
readCount Number | undefined

Read count of group message
To query which group members have read the message, call TUIChatService.getGroupMessageReadMemberList

unreadCount Number | undefined

Unread count of group message

isPeerRead Boolean | undefined

Whether peer has sent read receipt for C2C message

isBroadcastMessage Boolean false

Whether broadcast message to all live streaming groups (requires Ultimate edition)

isSupportExtension Boolean false

Whether message extension is supported (requires Ultimate edition)

revoker String | null

UserID of who revoked the message

progress Number

Upload progress for image/video/audio/file messages (0-100)

revokerInfo Object

Info of who revoked the message

Properties
Name Type Description
avatar String

Avatar of who revoked the message

nick String

Nickname of who revoked the message

userID String

UserID of who revoked the message

revokeReason String

Reason for revoking the message

hasRiskContent Boolean

Whether audio/video message is marked as risky content (default false)

reactionList Array.<ReactionInfo>

Requires Ultimate edition, will automatically get reaction summary after purchase and relogin

MessageModel handles message operations and display data processing. Developers don't need to implement it as it's provided by TUIChatEngine through ChatStore's messageList.

Methods

modifyMessage(options) → {Promise.<any>}

Modify message

Example
let promise = messageModel.modifyMessage(options);
promise.catch((error) => {
  // Handle errors through promise.catch
});
Parameters:
Name Type Description
options ModifyMessageParams

Modification content

Returns:
Type
Promise.<any>

revokeMessage() → {Promise.<any>}

Revoke message (sets isRevoked to true after success)

Example
let promise = messageModel.revokeMessage();
promise.catch((error) => {
  // Handle errors through promise.catch
});
Returns:
Type
Promise.<any>

resendMessage() → {Promise.<any>}

Resend failed message

Example
let promise = messageModel.resendMessage();
promise.catch((error) => {
  // Handle errors through promise.catch
});
Returns:
Type
Promise.<any>

deleteMessage() → {Promise.<any>}

Delete message (sets isDeleted to true after success)

Example
let promise = messageModel.deleteMessage();
promise.catch((error) => {
  // Handle errors through promise.catch
});
Returns:
Type
Promise.<any>

quoteMessage() → {Message}

Quote current message

Example
let message = messageModel.quoteMessage();
Returns:
Type
Message

replyMessage() → {Message}

Reply to current message

Example
let message = messageModel.replyMessage();
Returns:
Type
Message

getSignalingInfo() → {Record.<string, any>|null}

Get signaling info

Example
let signaling = messageModel.getSignalingInfo();
// signaling != null means it's a signaling message
// signaling = null means it's not a signaling message
if (signaling) {
  console.log(signaling)
}
Returns:
Type
Record.<string, any> | null

getSignalingInfo() → {Record.<string, any>|null}

Get message display content
Note 1: Default parsing behavior, customize parsing using messageModel fields if needed
Note 2: Doesn't support group system messages
Note 3: Group tip messages don't return showName
Note 4: showName priority:

  • C2C: remark > nick > userID
  • Group: remark > nameCard > nick > userID
Example
// Text message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.text - Text content
// result.name - Message name (text or img for emoji)
// result.type - Message type (custom for custom emoji)
// result.emojiKey - Emoji key
// result.src - Emoji display URL (empty for custom emoji)
Returns:
Type
Record.<string, any> | null

getMessageContent() → {Record.<string, any>}

Get message display content
Note 1: The following parsing is default behavior. For custom parsing, use messageModel fields directly.
Note 2: Group system messages are not supported.
Note 3: Group tip messages don't return showName.
Note 4: showName display priority:

  • C2C: remark > nick > userID
  • Group: remark > nameCard > nick > userID
Examples
// Text message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.text - Text content
// result.name - Message name (text or img, img means emoji message)
// result.type - Message type (custom for custom emoji, empty for default emoji and normal text) (supported since v2.2.0)
// result.emojiKey - Emoji key (supported since v2.2.0)
// result.src - Emoji display URL (empty for custom type, need to combine with baseUrl and emojiKey)
// Emoji message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.name - Emoji name
// result.type - Emoji type (custom for custom emoji, empty for default) (supported since v2.2.0)
// result.url - Emoji display URL (empty for custom type, need to combine with baseUrl and name)
// Location message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.lon - Longitude
// result.lat - Latitude
// result.href - Map jump link
// result.url - Map display link
// result.description - Description
// Image message result (original image by default, get thumbnail/large image from messageModel.payload)
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.url - Image URL
// result.width - Image width
// result.height - Image height
// Audio message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.url - Audio play URL
// result.second - Duration (seconds)
// Video message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.url - Video play URL
// result.snapshotUrl - Cover image URL
// result.snapshotWidth - Cover width
// result.snapshotHeight - Cover height
// File message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.url - File download URL
// result.name - File name
// result.size - File size
// Custom message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// result.custom - Custom content
// result.businessID - Business ID (group_create for group creation, empty for others)
// Merged message result
const result = messageModel.getMessageContent();
// result.showName - Sender name
// Content is from message.payload
// Group tip message result
const result = messageModel.getMessageContent();
// result.text - Group tip content
Returns:
Type
Record.<string, any>