Set periodic server message destruction
Enable, disable, and configure the periodic message destruction window on the server for a conversation.
Configure server-side retention policies to automatically delete aged messages from server stores after a specific expiration window:
Code example
import sdk, { SetConversationReq } from '@openimsdk/imsdk';
const request: SetConversationReq = {
conversationID: conversationID,
isMsgDestruct: true,
msgDestructTime: 3600,
};
await sdk.setConversation(request);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Target conversation identifier. |
isMsgDestruct | boolean | Yes | Set to true to enable automatic destruction; set to false to disable. |
msgDestructTime | number | Yes | Retention window in seconds before messages are purged on the server. |
Return value
Returns a Promise that resolves to void when the policy is applied.
State changes after the call
Set isMsgDestruct: false to disable server destruction. This setting deletes messages from server storage only; it does not purge messages already downloaded and cached locally on existing devices. Once deleted from the server, messages cannot be synchronized to newly installed devices or after clearing local caches. After the Promise resolves, the SDK emits EventOnConversationChanged. Match the item by conversationID and update isMsgDestruct and msgDestructTime, as detailed in Retrieve conversation list.
Was this page helpful?