Report offensive messages
Message Persistence
Enable Message Persistence in the Admin Portal.
Users can report offensive messages directly from your app. Reported messages publish to PUBNUB_INTERNAL_ADMIN_CHANNEL and emit report events.
Add custom logic using emitted events to handle reported messages (e.g., delete them).
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Message->ReportAsync(OnReportResponseDelegate, Reason);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatOperationResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatOperationResult Result = Message->Report(Reason);
Flag/Report messages
Report() flags a message for admin review.
Method signature
- Blueprint
- C++ / Input parameters
1Message->Report(FString Reason = "");
| Parameter | Description |
|---|---|
ReasonType: FStringDefault: "" | Reason for reporting/flagging a given message. |
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Result of the operation. Check Error and ErrorMessage for failure. |
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Report a message asynchronously.
Stream message report events
StreamMessageReports() subscribes to real-time report events on a channel. Bind the channel's OnMessageReported delegate before calling this method to receive report events.
note
Use this method for channels where you want live monitoring of reported messages, such as an admin moderation dashboard.
Method signature
1Channel->StreamMessageReports();
Bind the channel's OnMessageReported delegate before calling StreamMessageReports() to receive report events.
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Result of the operation. Check Error for failure. |
Sample code
Stream report events on the support channel.
1
Other examples
Stop streaming report events.
Actor.h
1
Actor.cpp
1
Get message reports history
GetMessageReportsHistory() retrieves historical report events from a channel, similar to GetHistory() for messages. Use this to audit past message reports.
Method signature
1Channel->GetMessageReportsHistory(
2 FString StartTimetoken,
3 FString EndTimetoken,
4 int Count = 100
5);
| Parameter | Description |
|---|---|
StartTimetokenType: FStringDefault: n/a | Timetoken delimiting the start of a time slice (exclusive) to pull report events from. |
EndTimetokenType: FStringDefault: n/a | Timetoken delimiting the end of a time slice (inclusive) to pull report events from. |
CountType: intDefault: 100 | Number of historical report events to return for the channel in a single call. Maximum: 100. |
Output
| Parameter | Description |
|---|---|
FPubnubChatEventsResultType: struct | Returned object containing Result, Events, and IsMore. |
→ ResultType: FPubnubChatOperationResult | Operation result with Error (bool), ErrorMessage (FString), and StepResults. |
→ EventsType: TArray<FPubnubChatEvent> | Array of historical report event objects. |
→ IsMoreType: bool | Indicates whether there are more historical events to pull. |
Sample code
Fetch the last 10 report events from the support channel.
1