> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-angular-v5-docs-update.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Moderation

> Flag messages for review and track moderation status.

The CometChat Unreal SDK provides moderation tools to let users report inappropriate content. You can flag messages with a reason, fetch available flag reasons, and track moderation status on messages.

***

## Flag a Message

Use the **Flag Message Async** node to report a message for moderation review.

<Tabs>
  <Tab title="Blueprint">
    <Frame>
      <img src="https://mintcdn.com/cometchat-22654f5b-docs-angular-v5-docs-update/I_XMOeTO0227yWLo/images/unreal-blueprints/FlagMessageAsync.png?fit=max&auto=format&n=I_XMOeTO0227yWLo&q=85&s=13ad4e5a9a937964457a2e3d6d254eae" width="747" height="311" data-path="images/unreal-blueprints/FlagMessageAsync.png" />
    </Frame>

    1. Create an `FCometChatFlagDetail` struct with the `ReasonId` and optional `Remark`
    2. Call the **Flag Message Async** node with the message ID and flag detail
    3. Handle **On Success** (message flagged) or **On Failure** (error)
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    void AMyActor::FlagMessage(const FString& MessageId)
    {
        FCometChatFlagDetail FlagDetail;
        FlagDetail.ReasonId = TEXT("spam");
        FlagDetail.Remark = TEXT("This message is spam");

        auto* Action = UCometChatFlagMessageAction::FlagMessage(this, MessageId, FlagDetail);
        Action->OnSuccess.AddDynamic(this, &AMyActor::HandleFlagSuccess);
        Action->OnFailure.AddDynamic(this, &AMyActor::HandleError);
        Action->Activate();
    }

    void AMyActor::HandleFlagSuccess()
    {
        UE_LOG(LogTemp, Log, TEXT("Message flagged successfully"));
    }
    ```
  </Tab>
</Tabs>

***

## Get Flag Reasons

Fetch the list of available reasons a user can select when flagging a message.

<Tabs>
  <Tab title="Blueprint">
    1. Call the **Get Flag Reasons Async** node (no parameters needed)
    2. On Success, iterate the returned `TArray<FCometChatFlagReason>`
    3. Display the reasons in a UI picker for the user to select from
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    void AMyActor::FetchFlagReasons()
    {
        auto* Action = UCometChatGetFlagReasonsAction::GetFlagReasons(this);
        Action->OnSuccess.AddDynamic(this, &AMyActor::HandleFlagReasons);
        Action->OnFailure.AddDynamic(this, &AMyActor::HandleError);
        Action->Activate();
    }

    void AMyActor::HandleFlagReasons(const TArray<FCometChatFlagReason>& Reasons)
    {
        for (const auto& Reason : Reasons)
        {
            UE_LOG(LogTemp, Log, TEXT("Reason: %s — %s"), *Reason.Name, *Reason.Description);
        }
    }
    ```
  </Tab>
</Tabs>

***

## Moderation Status on Messages

Every `FCometChatMessage` includes a `ModerationStatus` field of type `ECometChatModerationStatus`. Use this to filter or visually indicate moderated content in your UI.

```mermaid theme={null}
flowchart LR
    A["Message Sent"] --> B["Unmoderated"]
    B --> C{"Auto-moderation<br/>or manual review"}
    C -->|"Approved"| D["Approved ✓"]
    C -->|"Flagged"| E["Pending Review"]
    E -->|"Reviewer approves"| D
    E -->|"Reviewer rejects"| F["Disapproved ✗"]

    style A fill:#333,stroke:#666,color:#fff
    style B fill:#444,stroke:#888,color:#fff
    style C fill:#555,stroke:#999,color:#ccc
    style D fill:#333,stroke:#666,color:#fff
    style E fill:#444,stroke:#888,color:#fff
    style F fill:#333,stroke:#666,color:#fff
```

### ECometChatModerationStatus

| Value         | Description                             |
| ------------- | --------------------------------------- |
| `Unmoderated` | Message has not been moderated          |
| `Pending`     | Message is pending moderation review    |
| `Approved`    | Message has been approved by moderation |
| `Disapproved` | Message has been rejected by moderation |

### Real-Time Moderation Updates

Listen to the `OnMessageModerated` delegate to receive real-time updates when a message's moderation status changes:

<Tabs>
  <Tab title="Blueprint">
    Bind to **On Message Moderated** on the CometChat Subsystem. The event provides the updated `FCometChatMessage` with the new `ModerationStatus`.
  </Tab>

  <Tab title="C++">
    ```cpp theme={null}
    void AMyActor::BeginPlay()
    {
        Super::BeginPlay();

        UCometChatSubsystem* Chat = GetGameInstance()->GetSubsystem<UCometChatSubsystem>();
        Chat->OnMessageModerated.AddDynamic(this, &AMyActor::HandleMessageModerated);
    }

    void AMyActor::HandleMessageModerated(const FCometChatMessage& Message)
    {
        switch (Message.ModerationStatus)
        {
        case ECometChatModerationStatus::Approved:
            UE_LOG(LogTemp, Log, TEXT("Message %s approved"), *Message.Id);
            break;
        case ECometChatModerationStatus::Disapproved:
            UE_LOG(LogTemp, Log, TEXT("Message %s disapproved — hiding"), *Message.Id);
            HideMessage(Message.Id);
            break;
        default:
            break;
        }
    }
    ```
  </Tab>
</Tabs>

***

## FCometChatFlagDetail

The struct you provide when flagging a message.

| Property   | Type      | Description                                   |
| ---------- | --------- | --------------------------------------------- |
| `ReasonId` | `FString` | ID of the flag reason (from `GetFlagReasons`) |
| `Remark`   | `FString` | Optional free-text remark from the reporter   |

## FCometChatFlagReason

The struct returned when fetching available flag reasons.

| Property      | Type      | Description                               |
| ------------- | --------- | ----------------------------------------- |
| `Id`          | `FString` | Unique reason identifier                  |
| `Name`        | `FString` | Display name (e.g., "Spam", "Harassment") |
| `Description` | `FString` | Detailed description of the reason        |
| `CreatedAt`   | `int64`   | Creation timestamp                        |
| `UpdatedAt`   | `int64`   | Last update timestamp                     |

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Real-Time Events" icon="bolt" href="/sdk/unreal/real-time-events">
    Listen for moderation status changes in real time.
  </Card>

  <Card title="API Reference" icon="book" href="/sdk/unreal/reference">
    Complete reference of all structs and enums.
  </Card>
</CardGroup>
