a06673b
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize,
)]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum ChannelMemberRole {
#[default]
Member = 0,
Admin = 1,
Owner = 2,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "channel_member")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub channel_id: Uuid,
#[sea_orm(primary_key, auto_increment = false)]
pub user_id: Uuid,
#[sea_orm(default_value = "0")]
pub role: ChannelMemberRole,
#[sea_orm(default_value = "false")]
pub muted: bool,
pub muted_until: Option<OffsetDateTime>,
pub last_read_message_id: Option<Uuid>,
pub joined_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "channel_id", to = "id")]
pub channel: BelongsTo<super::channels::Entity>,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<super::super::user::users::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}