Sensitive Information Block Notification Callback
Note
The Web SDK supports the Sensitive Information Block Notification Callback starting from version 5.0.2.
If you are using RC's content moderation services (including message sensitive words, IM moderation services, and message callback services), you may want to notify the sender when a message is blocked due to triggering moderation rules. Starting from SDK version 5.0.2, the client SDK can trigger a callback to notify the sender when a message is blocked.
Messages may be blocked for containing sensitive information under the following circumstances:
- The content of a text message hits RC's built-in sensitive words, causing the message not to be delivered to the recipient.
- The content of a text message hits your custom sensitive words, causing the message not to be delivered to the recipient.
- The message hits the moderation rules set by the IM Moderation service or the Message Callback service, causing the message not to be delivered to the recipient.
Enabling the Service
You can enable the Blocked Message Status Callback to Sender feature by navigating to Configuration > Chat settings > Basic features > Security in the RC Console.
Setting Up the Sensitive Information Block Listener
You can set up a sensitive word block listener using the following method to monitor blocked messages and the reasons for blocking.
const listener = (blockedMessageInfo) => {
console.log('Message blocked due to sensitive information:', blockedMessageInfo)
}
RongIMLib.addEventListener(RongIMLib.Events.MESSAGE_BLOCKED, listener)
For details on removing the listener and the full list of events, refer to the IMLib documentation Event Listener.
Return Value Description
Parameter | Type | Description |
---|---|---|
blockedMessageInfo | IBlockedMessageInfo | Callback parameters for messages blocked due to sensitive information |
-
IBlockedMessageInfo
DescriptionAttribute Name Description blockType The reason the message was blocked. See MessageBlockType
Description below.blockedMessageUId The unique ID of the blocked message. channelId The channel ID of the conversation where the message was blocked (only applicable to messages in ultra groups). conversationType The conversation type of the conversation where the message was blocked. extra Additional information about the blocked message. Supported starting from Web SDK version 5.3.3. targetId The conversation ID of the conversation where the message was blocked. sourceType The source trigger type of the blocked message. See MessageBlockSourceType
Description below. (Only for ultra groups)sourceContent The source content object of the blocked message. When sourceType
is1
, it represents extended content; whensourceType
is2
, it represents message content. (Only for ultra groups) -
MessageBlockType
DescriptionEnum Value Value Description GLOBAL 1
Global sensitive words: The message hit RC's built-in global sensitive words. CUSTOM 2
Custom sensitive words: The message hit custom sensitive words set by the client in RC. THIRD_PARTY 3
Third-party moderation: The message hit moderation rules set by a third party (e.g., Shumei) or the message callback service (original template routing service) and was not delivered. -
MessageBlockSourceType
DescriptionEnum Value Value Description MSG_ORIGINAL 0 Original message MSG_EXPANSION 1 Message expansion MSG_MODIFY 2 Message modification