Message
Describes single message. Received via the MessengerEvents.SendMessage or MessengerEvents.EditMessage events and used to serialize or edit the message.
Methods
remove
remove(): Promise<RemoveMessageEvent>
Remove the message from the conversation. Triggers the MessengerEvents.RemoveMessage event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:
- Subscribe to the MessengerEvents.RemoveMessage event and provide a handler consuming an object with the EventHandlers.RemoveMessageEvent interface as a parameter. Remember that MessengerEvents.RemoveMessage may be triggered by another user, so check the 'initiator' field.
- Handle the returned promise. Though you still need to listen to MessengerEvents.RemoveMessage event to handle events from other parties. Rejects to a Messaging.MessengerError if
- the current user cannot remove own messages (see ConversationParticipant.canRemove and ConversationParticipant.isOwner),
- the current user cannot remove other partisipants' messages (see ConversationParticipant.canRemoveAll and ConversationParticipant.isOwner).
Returns
type:
Promise<RemoveMessageEvent>
toCache
toCache():
Serialize the message so it can be stored (e.g. in IndexedDB) and later restored via the [Messenger2.createMessageFromCache] method
Returns
type:
update
update(): Promise<EditMessageEvent>
Send text and payload changes to the cloud. Triggers the MessengerEvents.EditMessage event for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:
- Subscribe to the MessengerEvents.EditMessage event and provide a handler consuming an object with the EventHandlers.EditMessageEvent interface as a parameter. Remember that MessengerEvents.EditMessage may be triggered by another user, so check the 'initiator' field.
- Handle the returned promise. Though you still need to listen to MessengerEvents.EditMessage event to handle events from other parties. Rejects to a Messaging.MessengerError if
- the current user cannot edit own messages (see ConversationParticipant.canEdit and ConversationParticipant.isOwner),
- the current user cannot edit other partisipants' messages (see ConversationParticipant.canEditAll and ConversationParticipant.isOwner).
Returns
type:
Promise<EditMessageEvent>
Props
conversation
conversation: string
The UUID of the conversation this message belongs to.
payload
payload: Object[]
Array of payload objects associated with the message. Setting this property does not send changes to the cloud. Use the Message.update method to send all the changes at once.
text
text: string
Message text. Setting this property does not send changes to the cloud. Use the Message.update method to send all the changes at once.
uuid
uuid: string
The universally unique identifier (UUID) of the message. Can be used on client side for housekeeping.