Report offensive messages

PubNub provides a mechanism for users to report offensive content in messages directly from their applications. A moderator can then fetch these flagged messages from Message Persistence and either delete them or take appropriate action against the users who sent the messages.

User ID / UUID

User ID is also referred to as UUID/uuid in some APIs and server responses but holds the value of the userId parameter you set during initialization.

Flag messages

Use the addMessageAction method to add a flag as an action to a published message. The flag is stored and linked to the original message, so you can see if messages are flagged or not when you fetch them from Message Persistence.

1pubnub.addMessageAction(
2 {
3 channel: 'ch-1'
4 messageTimetoken: '15610547826970040',
5 action: {
6 type: 'flagged',
7 value: 'message is inappropriate',
8 },
9 },
10 function(status, response) {
11
12 }
13);

Unflag messages

Use the removeMessageAction method to remove a flag from a message.

1pubnub.removeMessageAction(
2{
3 channel: 'ch-1'
4 messageTimetoken: '15610547826970040',
5 actionTimetoken: '15610547826970040',
6},
7function(status, response) {
8}
9);

Flagging Events

PubNub triggers events when flags are added or removed. Users that are subscribed to channels will receive these events.

Message reaction added:

1{
2 "channel":"my_channel",
3 "subscription":null,
4 "timetoken":"15871508399473609",
5 "publisher":"user-1",
6 "message":{
7 "source":"actions",
8 "version":"1.0",
9 "action":"added",
10 "data":{
11 "type":"flagged",
12 "value":"message is inappropriate",
13 "messageTimetoken":"15632184115444390",
14 "actionTimetoken":"15632184115444394"
15 }
show all 17 lines

Message reaction removed:

1{
2 "channel":"my_channel",
3 "subscription":null,
4 "timetoken":"15871508399473609",
5 "publisher":"user-1",
6 "message":{
7 "source":"actions",
8 "version":"1.0",
9 "action":"removed",
10 "data":{
11 "type":"flagged",
12 "value":"message is inappropriate",
13 "messageTimetoken":"15632184115444390",
14 "actionTimetoken":"15632184115444394"
15 }
show all 17 lines
Last updated on