//! `SeaORM` Entity for comments on tickets and patch proposals.

use sea_orm::entity::prelude::*;
use serde::Serialize;

#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize)]
#[sea_orm(table_name = "comments")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    #[sea_orm(unique)]
    pub uuid: Uuid,
    /// The local user who wrote this comment (null for remote-authored comments).
    pub author_id: Option<i64>,
    /// The remote actor who wrote this comment (for federated comments).
    /// Exactly one of author_id or remote_actor_id is set.
    pub remote_actor_id: Option<i64>,
    /// The remote Note id, for idempotency on federation.
    pub remote_object_id: Option<String>,
    /// The ticket this comment belongs to, if any.
    pub ticket_id: Option<i64>,
    /// The patch proposal this comment belongs to, if any.
    pub patch_proposal_id: Option<i64>,
    /// The comment content in markdown or HTML.
    pub content: String,
    /// The format of the content: 'markdown' (default) or 'html' (for remote content).
    pub content_format: String,
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: Option<DateTimeWithTimeZone>,
}

impl ActiveModelBehavior for ActiveModel {}
