Report offensive messages
Unity Chat SDK provides a mechanism for users to report offensive content in messages directly from their applications.
In each case, a user must provide a reason for flagging a given message. As a result of flagging, a reported message gets published on the dedicated administrative channel (with the ID of PUBNUB_INTERNAL_MODERATION_{channel_id}) and an event of the report type gets created.
As a developer, you can add custom logic that uses the emitted events and defines what an admin can later do with such reported messages. For example, an admin can delete an inappropriate message.
Message Persistence
To work with stored message data, make sure you have Message Persistence enabled for your app's keyset in the Admin Portal.
Flag/Report messages
Report() lets you flag and report an inappropriate message to the admin.
All messages (events of type report) reported on a given channel are sent to a PUBNUB_INTERNAL_MODERATION_{channel_id} channel which is a child channel for the main one where a reported message was published. For example, an event on a message reported on the support channel will be sent to the PUBNUB_INTERNAL_MODERATION_support channel.
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
As an admin of your chat app, you can monitor all events emitted when someone reports an offensive message using the SetListeningForReportEvents() method.
You can use this method to create moderation dashboard alerts.
Events documentation
To read more about the events of type Report, refer to the Chat events documentation.
Method signature
This method has the following parameters:
1// start listening
2channel.SetListeningForReportEvents(bool listen)
3
4// triggered report event
5public event Action<ReportEvent> OnReportEvent;
6// needs a corresponding event handler
7void EventHandler(ReportEvent event)
Input
| Parameter | Description |
|---|---|
channelIdType: stringDefault: n/a | Channel to listen for new report events. |
Output
This method doesn't return anything.
Sample code
Print a notification for an offensive message reported on the support channel.
1