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.

pubnub.addMessageAction(
{
channel: 'ch-1'
messageTimetoken: '15610547826970040',
action: {
type: 'flagged',
value: 'message is inappropriate',
},
},
function(status, response) {

}
);

Unflag Messages

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

pubnub.removeMessageAction(
{
channel: 'ch-1'
messageTimetoken: '15610547826970040',
actionTimetoken: '15610547826970040',
},
function(status, response) {
}
);

Flagging Events

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

Message action added:

{
"channel":"my_channel",
"subscription":null,
"timetoken":"15871508399473609",
"publisher":"user-1",
"message":{
"source":"actions",
"version":"1.0",
"action":"added",
"data":{
"type":"flagged",
"value":"message is inappropriate",
"messageTimetoken":"15632184115444390",
"actionTimetoken":"15632184115444394"
}
show all 17 lines

Message action removed:

{
"channel":"my_channel",
"subscription":null,
"timetoken":"15871508399473609",
"publisher":"user-1",
"message":{
"source":"actions",
"version":"1.0",
"action":"removed",
"data":{
"type":"flagged",
"value":"message is inappropriate",
"messageTimetoken":"15632184115444390",
"actionTimetoken":"15632184115444394"
}
show all 17 lines
Last updated on