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​

* 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​

StreamReportEvents() monitors report events for moderation dashboards. Use OnMessageReported 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)
  • OnMessageReported - Event signature

    1// event on the Channel entity — enabled by StreamReportEvents()
    2public event Action<MessageReport> OnMessageReported;
    3// needs a corresponding event handler
    4void EventHandler(MessageReport report)

Input​

ParameterRequired in StreamReportEvents()Required in OnMessageReportedDescription
stream
Type: bool
Default:
n/a
Yesn/aWhether to start (true) or stop (false) listening to report events on the channel. Events are sent to the PUBNUB_INTERNAL_MODERATION_{channel_id} channel.
report
Default:
n/a
NoYesTyped report data containing the flagged message text, reason, timetoken, channel ID, and reporter's user ID.

Output​

These methods don't return a value. Report event updates are delivered through the OnMessageReported event handler.

Sample code​

Print a notification for an offensive message reported on the support channel.

1

Was this page useful?

Last updated on