# Modèle de données - Modération

📖 Voir [Règles métier - Section 14 : Modération Flows](../rules/moderation-flows.md) | [Entités globales](../../_shared/entities/modele-global.md)

## Diagramme

```mermaid
erDiagram
    REPORTS }o--|| USERS : "signalé par"
    REPORTS }o--|| CONTENTS : "concerne"
    REPORTS }o--|| MODERATORS : "traité par"
    REPORTS ||--o| SANCTIONS : "génère"
    REPORTS ||--o| APPEALS : "fait l'objet de"

    SANCTIONS }o--|| CONTENTS : "sanctionne"
    SANCTIONS }o--|| USERS : "sanctionne créateur"
    SANCTIONS ||--o{ STRIKES : "crée"

    APPEALS }o--|| REPORTS : "conteste"
    APPEALS }o--|| USERS : "soumis par"
    APPEALS }o--|| MODERATORS : "examiné par"

    STRIKES }o--|| USERS : "attribué à"
    STRIKES }o--|| SANCTIONS : "provient de"

    MODERATION_BADGES }o--|| USERS : "possédé par"

    REPORTS {
        uuid id PK
        uuid content_id FK
        uuid reporter_id FK
        uuid moderator_id FK
        string category
        text comment
        string status
        text transcription
        int ai_score
        int priority
        string decision
        timestamp created_at
        timestamp reviewed_at
        timestamp closed_at
        boolean is_auto_action
    }

    SANCTIONS {
        uuid id PK
        uuid report_id FK
        uuid content_id FK
        uuid creator_id FK
        string sanction_type
        int duration_days
        text reason
        text excerpt_timestamp
        timestamp applied_at
        timestamp expires_at
        boolean is_active
    }

    STRIKES {
        uuid id PK
        uuid creator_id FK
        uuid sanction_id FK
        int strike_number
        timestamp applied_at
        timestamp expires_at
        boolean is_active
    }

    APPEALS {
        uuid id PK
        uuid report_id FK
        uuid creator_id FK
        uuid moderator_id FK
        string ticket_number UK
        string status
        text reason
        text arguments
        text moderator_justification
        string decision
        timestamp created_at
        timestamp reviewed_at
        timestamp closed_at
    }

    MODERATORS {
        uuid id PK
        string name
        string role
        int reviews_count
        decimal avg_review_time_minutes
        timestamp last_active
    }

    MODERATION_BADGES {
        uuid id PK
        uuid user_id FK
        string badge_type
        int reports_validated
        int reports_rejected
        decimal accuracy_rate
        timestamp obtained_at
        timestamp last_audit_at
        boolean is_active
    }
```

## Légende

**Entités spécifiques modération** :

- **REPORTS** : Signalements - 7 catégories (`hate_violence`, `sexual_content`, `illegal`, `copyright`, `spam`, `misinformation`, `other`) - Status : `received` → `transcribing` → `analyzing` → `pending_review` → `in_review` → `validated`/`rejected` → `closed` - Scoring IA 0-100%, priorité calculée
- **SANCTIONS** : Sanctions créateurs - Types : `warning`, `strike`, `suspension_7d`, `suspension_30d`, `ban_permanent` - Durée selon type (7j, 30j, permanent)
- **STRIKES** : Compteur strikes - 1/4 à 4/4 (Strike 4 = ban permanent) - Expiration après 6 mois
- **APPEALS** : Appels sanctions - Ticket format `#MOD-YYYY-XXXXX` - Status : `pending`, `in_review`, `accepted`, `rejected`, `expired` - Délai soumission 7j, traitement 72h (standard) ou 5j (complexe)
- **MODERATORS** : Modérateurs - Rôles : `junior_moderator`, `senior_moderator`, `admin_moderation`
- **MODERATION_BADGES** : Badges contributeurs - Types : `bronze` (5 validés, 70%), `silver` (20 validés, 80%), `gold` (50 validés, 90%) - Audit trimestriel révocation si critères non respectés
