editMessage()
method. This method takes an object of the BaseMessage
class. At the moment, you are only allowed to edit TextMessage
and CustomMessage
. Thus, the BaseMessage
object must either be a Text or a Custom Message.
setTags()
method to do so. The tags added while editing a message will replace the tags set when the message was sent.
editMessage()
method and pass the message object to it.
onSucess()
callback method of the listener. The message object will contain the editedAt
field set with the timestamp of the time the message was edited. This will help you identify if the message was edited while iterating through the list of messages. The editedBy
field is also set to the UID
of the user who edited the message.
By default, CometChat allows certain roles to edit a message.
User Role | Conversation Type | Edit Capabilities |
---|---|---|
Message Sender | One-on-one Conversation | Messages they’ve sent |
Message Sender | Group Conversation | Messages they’ve sent |
Group Owner | Group Conversation | All messages in the group |
Group Moderator | Group Conversation | All messages in the group |
onMessageEdited()
method of the MessageListener
class.
editedAt
and the editedBy
fields will be set. Also, for example, if the total number of messages for a conversation is 100, and the message with message ID 50 was edited. Now the message with ID 50 will have the editedAt
and the editedBy
fields set whenever it is pulled from the history. Also, the 101st message will be an Action
message informing you that the message with ID 50 has been edited..
For the message edited event, in the Action
object received, the following fields can help you get the relevant information-
action
- edited
actionOn
- Updated message object with the edited details.actionBy
- User object containing the details of the user who has edited the message.actionFor
- User/group object having the details of the receiver to which the message was sent.