Restore messages
restore() recovers soft-deleted messages and their attached files. Hard-deleted messages cannot be restored.
Requires Message Persistence
Enable Message Persistence and Enable Delete-From-History in the Admin Portal.
Method signature
This method has the following signature:
1message.restore()
2: Promise<Message>
Input
This method doesn't take any parameters.
Output
| Type | Description |
|---|---|
Promise<Message> | Object returning the restored Message object. |
Sample code
Restore a previously soft deleted message with the 16200000000000001 timetoken.
1// reference the "message" object
2const message = await channel.getHistory({
3 startTimetoken: "16200000000000000",
4 endTimetoken: "162000000000000001"
5})
6// soft delete this message
7await message.delete({
8 soft: true
9})
10
11// restore the deleted message
12await message.restore()