# Flag/Unflag a Message

## Flag a Message

The Chat SDK product also includes a flag method that allows users to flag messages in their app. Once a message is flagged, an indicator will appear in the Admin console, where an administrator can review and validate the flag. If the content is found to be in violation of your app's policies, it can be deleted from the app. On the other hand, if the content is not found to be in violation, the flag can be revoked.

The flag method provides an essential tool for managing user-generated content in your app, ensuring that inappropriate messages can be quickly identified and removed. By integrating this method into your app's user interface, you can empower your users to take an active role in promoting a safe and respectful community.&#x20;

To use the function you simply need to identify the `messageId` that you'd like to flag with reason that we provided, users can help ensure that the community remains a safe and welcoming place for all members.

| AmityContentFlagReason       | Description                            |
| ---------------------------- | -------------------------------------- |
| CommunityGuidelines          | Against community guidelines           |
| HarassmentOrBullying         | Harassment or bullying                 |
| SelfHarmOrSuicide            | Self-harm or suicide                   |
| ViolenceOrThreateningContent | Violence or threatening content        |
| SellingRestrictedItems       | Selling and promoting restricted items |
| SexualContentOrNudity        | Sexual message or nudity               |
| SpamOrScams                  | Spam or scams                          |
| FalseInformation             | False information or misinformation    |
| Others                       | Optional explanation (Max. 300 chars)  |

{% hint style="info" %}
Flag reason is only available in iOS, Android, and TypeScript
{% endhint %}

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/a7fa0c20dc4bacdb8b344077dec08d49>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/amythee/3934eb31584f1b0807f7b5cf83a8df44>" %}
{% endtab %}

{% tab title="JavaScript" %}

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

```javascript
flagRepo.flag()
```

{% endtab %}

{% tab title="TypeScript" %}
{% embed url="<https://gist.github.com/0ae97255d8edbf9b7c2534a89dec9b7e>" %}
{% endtab %}

{% tab title="Flutter" %}
{% embed url="<https://gist.github.com/amythee/2a66124969de71a35a81779f27644f03>" %}
{% endtab %}
{% endtabs %}

## Unflag a Message

Another useful feature is the unflag method, which enables users to revoke a previously flagged message. If a user flags a message by mistake or if the message is found not to violate your app's policies after review, the unflag method can be used to remove the flag from the message. It ensures that users have control over the content they flag and the ability to reverse their flag if necessary.

Similar to the flag function,  you simply need to identify the `messageId` that you'd like to unflag.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/c79c25de79465fad0bdab09a634fb28f>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/amythee/af5a11ebdf2d38fdac63c2aa3fc226d9>" %}
{% endtab %}

{% tab title="JavaScript" %}

```javascript
flagRepo.unflag()
```

{% endtab %}

{% tab title="TypeScript" %}
{% embed url="<https://gist.github.com/b376eddb122b1ca5dda6d331d92c1e91>" %}
{% endtab %}

{% tab title="Flutter" %}
{% embed url="<https://gist.github.com/amythee/74827599992fd693530f96cf68d7e7cc>" %}
{% endtab %}
{% endtabs %}

## Check if Message is Flagged <a href="#check-if-message-is-flagged" id="check-if-message-is-flagged"></a>

The `isFlaggedByMe` method allows users to check whether they have previously flagged a particular message. This method provides a convenient way for users to keep track of the content they have flagged and to ensure that they are staying up-to-date with their moderation activities.

By using the isFlaggedByMe method, your app's users can quickly determine whether they have already flagged a particular message and avoid duplicating their efforts.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/b1c2596722af98436d0bfecc4f6c2119>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/amythee/e0b9eaa2e20d123b570492b968b4e600>" %}
{% endtab %}

{% tab title="JavaScript" %}

```java
const result = await flagRepo.isFlaggedByMe()
```

{% endtab %}

{% tab title="TypeScript" %}
{% embed url="<https://gist.github.com/9855b299374b79d157c9638e561745b7>" %}
{% endtab %}

{% tab title="Flutter" %}
{% embed url="<https://gist.github.com/amythee/a152b71bf183afe0c58acdb7a8dd5bdd>" %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/social-plus-sdk/chat/messaging/flag-unflag-a-message.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
