Flag/Unflag Messages

Before flagging and unflagging a message, the related message must be fetched from the server first using either of these methods:

Flag message

To flag a message, call the following method:

try {
  await MessageRepository.flag('messageId');
  console.log('message is flagged');
} catch (error) {
  console.error('can not flag message', error);
}

Unflag message

To unflag a message, call the following method:

try {
  await MessageRepository.unflag('messageId');
  console.log('message is unflagged');
} catch (error) {
  console.error('can not unflag message', error);
}

Check if message is flagged

You can also check if you have previously flagged the message before by calling the following asynchronous method:

try {
  const isFlagged = await MessageRepository.isFlaggedByMe('messageId');
  
  if (isFlagged) {
    console.log('message is flagged by me');
  } else {
    console.log('message is not flagged by me');
  }
} catch (error) {
  console.error('can not identify if message is flagged by me', error);
}

Last updated