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).
Flag/Report messages
Report() flags a message for admin review.
Method signature
- Blueprint
- C++ / Input parameters
1Message->Report(FString Reason);
* required
| Parameter | Description |
|---|---|
Report *Type: FString | Reason for reporting/flagging a given message. |
Output
This method doesn't return any value.
Sample code
Report a message on the support channel as offensive.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FString Timetoken = "16200000000000001";
12
13// Fetch the message
14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
15
show all 16 linesListen to report events
ListenForEvents() monitors report events for moderation dashboards.
Events documentation
See Chat events for report event details.
Method signature
- Blueprint
- C++ / Input parameters
1Chat->ListenForEvents(
2 FString ChannelID,
3 EPubnubChatEventType ChatEventType,
4 FOnPubnubEventReceived EventCallback
5);
* required
| Parameter | Description |
|---|---|
ChannelID *Type: FStringDefault: n/a | Channel to listen for new report events. Set this value to a dedicated PUBNUB_INTERNAL_ADMIN_CHANNEL where all report events are sent. |
ChatEventTypeType: EPubnubChatEventTypeDefault: n/a | Type of events. PCET_REPORT is the type defined for all events emitted when an offensive message is flagged/reported. |
EventCallback *Type: FOnPubnubEventReceivedDefault: n/a | Callback function passed as a parameter. It defines the custom behavior to be executed whenever an invite event type is detected on the specified channel. |
EPubnubChatEventType
| Value | Description |
|---|---|
PCET_TYPING | Indicates a user is typing a message. Displayed as Typing. |
PCET_REPORT | Represents an event where a message has been flagged or reported for offensive content. Displayed as Report. |
PCET_RECEIPT | Confirms receipt of a message or event. Displayed as Receipt. |
PCET_MENTION | Indicates that a user has been mentioned in a message. Displayed as Mention. |
PCET_INVITE | Represents an invitation event typically sent to a specific user. Displayed as Invite. |
PCET_CUSTOM | Custom event type for specialized behavior or use cases. Displayed as Custom. |
PCET_MODERATION | Represents an event related to content moderation actions. Displayed as Moderation. |
Output
This method doesn't return any value.
Sample code
Print a notification for an offensive message reported on the support channel.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FString Timetoken = "16200000000000001";
12
13// Fetch the message
14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
15
show all 27 lines