use sea_orm::entity::prelude::*;
use uuid::Uuid;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "direct_messages")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub sender_user_id: Uuid,
    pub recipient_user_id: Uuid,
    pub body: String,
    pub created_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::users::Entity",
        from = "Column::SenderUserId",
        to = "super::users::Column::Id"
    )]
    SenderUser,
    #[sea_orm(
        belongs_to = "super::users::Entity",
        from = "Column::RecipientUserId",
        to = "super::users::Column::Id"
    )]
    RecipientUser,
}

impl ActiveModelBehavior for ActiveModel {}
