Moderate users and messages
Chat SDK provides a few ways to moderate users and messages.
Flag messages
If a chat user wants to report/flag an offensive behavior to the chat admin, they can flag a message. You must provide a reason for reporting a given message.
Mute users
- As an admin
- As a user
Admins can block users from posting messages on channels by muting them.
You can set up Access Manager in your app and take the write
access away from the muted user. As a result, this user cannot send messages to that channel but can still see messages published by others (read
access).
Mute list and Access Manager
If you use Access Manager for user moderation within your chat app, and your users use the client-side mute list functionality with the syncMutedUsers
parameter enabled, you must grant the Chat SDK user the following permissions:
read
permission to thePN_PRV.$currentUserId.mute1
channel.update
,delete
, andget
permissions for thePN_PRV.$currentUserId.mute1
user.
Make sure to change $currentUserId
to the user ID of the chat user that will use the mute list functionality.
Requires Secret Key authentication
Mute and ban restrictions should be set by administrators whose Chat SDK instance has been initialized with a Secret Key (available on the Admin Portal on your app's keyset).
The secretKey
must be used within a secure server and never exposed to client devices. If it's ever compromised, it can be an extreme security risk to your application. If you suspect your secretKey
has been compromised, you can generate a new one for the existing PubNub keyset on the Admin Portal.
Regular Chat SDK users can mute users on their clients.
A user who muted another on their client won't be able to see any incoming or historical messages from the muted user. Other chat users will still be able to see their messages.
The user IDs that a given chat user wants to hide messages from (mute them) are saved to a list. This mute list can hold up to 200 users and, by default, is only persisted for the duration of the user session. A local mute list can be saved and retrieved during initialization, effectively persisting the mute list.
Ban users
Admins can block users from posting nad reading messages on channels by banning them.
You can set up Access Manager in your app and take the read
and write
access away from the banned user. As a result, this user cannot send messages to that channel and read any messages published by others.
Check user restrictions
Chat SDK provides methods for verifying if a given user is muted or banned on a given channel by checking user restrictions.
In your chat app, you may want to implement a logic that verifies these permissions for users to prevent them from performing some operations in the chat app. For example, you can check if a user is muted before they try to post a message on a channel, or verify if they are banned before they attempt to join a given channel.
It's highly recommended to use both moderation restrictions and Access Manager rules in your app. The permissions schema defined in Access Manager is verified against the moderation restrictions set in the Chat SDK before access is provided. This way, you ensure that an unauthorized person won't perform unauthorized operations on PubNub channels and other users' metadata.
Listen to flagging events
Chat SDK lets you monitor as an admin if anyone reported an offensive message by listening to reported message events.
Handle flagging events
Based on the information provided by Chat SDK, you can code your own additional moderation logic. For example, you can integrate your app with third-party services through PubNub Integrations. You can import some of these integrations from within Admin Portal (in the Functions tab) and quickly integrate your app with third-party services to add profanity filtering for messages.
Prevent message spamming
Chat SDK also lets you set the client-side limit (expressed in milliseconds) that states the rate at which messages can be published on a given channel type (you can set different limits for direct, group, and public channels) by configuring the rateLimitPerChannel
and rateLimitFactor
options when initializing the Chat SDK. This way, you can stop users from spamming on your application.
Read the Configuration document for all the details.