Report offensive messages
Users can report offensive messages directly from your app. Reported messages publish to PUBNUB_INTERNAL_MODERATION_{channel_id} and emit report events.
Add custom logic using emitted events to handle reported messages (e.g., delete them).
Message Persistence
Enable Message Persistence in the Admin Portal.
Flag/Report messages
Report() flags a message for admin review. Reports publish to PUBNUB_INTERNAL_MODERATION_{channel_id} (e.g., reporting on support sends to PUBNUB_INTERNAL_MODERATION_support).
Method signature
This method takes the following parameters:
1message.Report(string reason)
Input
| Parameter | Description |
|---|---|
reason *Type: stringDefault: n/a | Reason for reporting/flagging a given message. |
Output
An awaitable Task<ChatOperationResult>.
Sample code
Report the last message on the support channel as offensive.
1
Listen to Report events
StreamReportEvents() monitors report events for moderation dashboards. Use OnReportEvent to handle report updates.
Events documentation
To read more about the events of type Report, refer to the Chat events documentation.
Method naming
Earlier versions used SetListeningForReportEvents() to enable streaming. This method has been superseded by StreamReportEvents(), though it remains available for backward compatibility.
Method signature
These methods take the following parameters:
-
StreamReportEvents()1channel.StreamReportEvents(bool stream) -
OnReportEvent- Event signature1// event on the Channel entity
2public event Action<ChatEvent> OnReportEvent;
3// needs a corresponding event handler
4void EventHandler(ChatEvent reportEvent)
Input
| Parameter | Required in StreamReportEvents() | Required in OnReportEvent | Description |
|---|---|---|---|
streamType: boolDefault: n/a | Yes | n/a | Whether to start (true) or stop (false) listening to report events on the channel. Events are sent to the PUBNUB_INTERNAL_MODERATION_{channel_id} channel. |
reportEventType: ChatEventDefault: n/a | No | Yes | The report event containing information about the reported message. |
Output
These methods don't return a value. Report event updates are delivered through the OnReportEvent event handler.
Sample code
Print a notification for an offensive message reported on the support channel.
1