Moderate misbehaving users
Regular chat users (without SecretKey) can mute undesirable users to hide their messages. For admin moderation, see Moderation as admin.
Mute list behavior:
- Soft limit: 200 users
- Default: session-only persistence
- Optional: persist across sessions (32KiB server limit applies)
Mute list limit
Persisted lists exceeding 32KiB (~200 users) trigger HTTP 413 errors. Users remain muted for the session but won't persist.
Affected methods:
channel.Connect()channel.Join()channel.GetMessageHistory()chat.ListenForEvents()chat.GetEventsHistory()
note
Enable App Context in the Admin Portal to mute users.
Mute users as a regular chat user
Mute a specific user on all channels.
Method signature
1chat.MutedUsersManager.MuteUser(string userId)
Input
| Parameter | Description |
|---|---|
userId *Type: string | User ID of the user you want to mute. |
Output
This method returns a Task<ChatOperationResult> that succeeds when the data has been synced with the server. If SyncMutedUsers is not enabled, the Task<ChatOperationResult> always succeeds.
Errors
If the size of the mute list exceeds 32KiB (roughly 200 users), you'll get the HTTP 413 (Request Entity Too Large) error.
Sample code
1
Unmute users as a regular chat user
Remove a user from the mute list to see their messages and events again.
Method signature
1chat.MutedUsersManager.UnMuteUser(string userId)
Input
| Parameter | Description |
|---|---|
userId *Type: string | User ID of the user you want to unmute. |
Output
This method returns a Task<ChatOperationResult> that succeeds when the data has been synced with the server. If SyncMutedUsers is not enabled, the Task<ChatOperationResult> always succeeds.
Sample code
1
Check muted users
Inspect the mute list to see which users are muted.
Method signature
1chat.MutedUsersManager.MutedUsers
Output
This property returns a List<string> where each string is a user ID of a muted user.
Sample code
1
Persist the mute list
Set SyncMutedUsers: true during client initialization to persist the mute list across sessions.
Mute list and Access Manager
If you use Access Manager for user moderation within your chat app and SyncMutedUsers is enabled, you must grant the Chat SDK user the following permissions:
readpermission to thePN_PRV.$currentUserId.mute1channel.update,delete, andgetpermissions for thePN_PRV.$currentUserId.mute1user.
Make sure to change $currentUserId to the user ID of the chat user that will use the mute list functionality.
Check restrictions
Check admin-imposed mute or ban restrictions:
Sample code
Single user on a single channel
1
All users on a single channel
1
Single user on all channels
1
Secure moderation
Client-side restrictions can be bypassed without server-side logic using Access Manager. Combine with client-side UI feedback to inform users of restrictions.
Client-side restrictions
With server-side permissions enforced via Access Manager, read moderation restrictions on the frontend to show users their status (e.g., popup messages, disabled input fields).
To react to permission changes in real-time:
-
Listen for moderation events. Set up a listener to listen for the
moderationevent type ("banned," "muted," or "lifted") generated when UI restrictions are added or removed.1 -
Remove the event listener.
Remember to unsubscribe from the event when you're done:
1user.OnModerationEvent -= OnModerationEventHandler;
2user.StreamModerationEvents(false);