Set message destruct
Enable, disable, and configure the periodic server-side message self-destruction policy for a conversation.
Periodic server-side message self-destruction is a Commercial Edition capability. The policy is controlled by two complementary properties: isMsgDestruct toggles the feature, and msgDestructTime specifies the destruction interval in seconds. Both properties belong to the same logical operation and can be committed in a single invocation.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationID | string | Yes | Identifier of the target conversation. |
isMsgDestruct | boolean | Yes | Set to true to enable server-side message self-destruction, or false to disable it. |
msgDestructTime | number | Yes | Self-destruction retention interval in seconds (for example, 3600 for one hour). |
Code example
import { setConversation } from '@/uni_modules/unix-openim-sdk'
await setConversation({
conversationID,
isMsgDestruct: true,
msgDestructTime: 3600,
})To disable the policy, pass isMsgDestruct: false. This mechanism governs message retention on OpenIMServer; it does not replace or interfere with single-chat burn-after-reading mode, which is configured in Set private chat and Set burn duration.
When messages reach the expiration interval, the server purges them from remote storage. Messages that have already synchronized to local device databases are not deleted automatically. However, new client installations, devices that clear local cache, or newly logged-in sessions cannot retrieve purged messages from the server.
Return value
The Promise resolves with void upon successful completion.
State changes after the call
Promise resolution indicates that the configuration was updated locally and saved to the server. You can immediately update the local conversation item's isMsgDestruct and msgDestructTime fields. The SDK then emits onConversationChanged, where you can verify the persisted state using conversationID as the primary key. For the centralized conversation list listener, see Retrieve conversation list.
Was this page helpful?