f0a1552
ZhenYi
feat(chat): add chat module with room management, message handling, and session revocation
f0a1552
use sea_orm::entity::prelude::*;
use time::OffsetDateTime;
use uuid::Uuid;
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "user_devices")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(unique_key = "user_device")]
pub user_id: Uuid,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<super::user::Entity>,
pub device_name: Option<String>,
pub device_type: Option<String>,
#[sea_orm(unique_key = "user_device")]
pub device_hash: String,
// 与 user_session.user_agent_hash 一致,UA 属于指纹数据,禁止明文落库
pub user_agent_hash: Option<String>,
pub os: Option<String>,
pub last_ip_hash: Option<String>,
pub last_seen_at: OffsetDateTime,
pub first_seen_at: OffsetDateTime,
pub is_trusted: bool,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
}
impl ActiveModelBehavior for ActiveModel {}