Flagging a message

Flag and Unflag a message

While having moderators surveying your chats is great, it doesn't scale well. A way to overcome this is to let your users do the work for your moderators. By letting users flag other users or specific messages, the work of moderators is significantly reduced and democratized, thus, allowing administrators to only respond to issues when deemed critical or absolutely necessary.

Flag and Unflag Messages

Users can flag messages and unflag messages that they have flagged using the MessageFlagRepository class.

import { MessageFlagRepository } from '@amityco/js-sdk';
const flagRepo = new MessageFlagRepository('message1');

Flag a message

To flag a message, call the following method:

flagRepo.flag()

Unflag a message

To unflag a message, call the following method:

flagRepo.unflag()

Check if the message has been flagged

The User can also check if they have previously flagged the message before by calling the following asynchronous method:

const result = await flagRepo.isFlaggedByMe()

If this method has been called before in the current session, the user can also check the cached result on the message payload itself.

// Note. If the value is undefined, it means the data has not been cached
message.isFlaggedByMeCache

Last updated