On this page

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

* required
ParameterDescription
reason *
Type: string
Default:
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.

Use the StreamReportEvents() method to enable or disable report event streaming on a channel, and the OnReportEvent event to handle report updates. You can use this to create moderation dashboard alerts.

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 signature

    1// event on the Channel entity
    2public event Action<ChatEvent> OnReportEvent;
    3// needs a corresponding event handler
    4void EventHandler(ChatEvent reportEvent)

Input

ParameterRequired in StreamReportEvents()Required in OnReportEventDescription
stream
Type: bool
Default:
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.
reportEvent
Type: ChatEvent
Default:
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

Last updated on