contact.rs

 1use crate::db::{ContactId, UserId};
 2use sea_orm::entity::prelude::*;
 3
 4#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel)]
 5#[sea_orm(table_name = "contacts")]
 6pub struct Model {
 7    #[sea_orm(primary_key)]
 8    pub id: ContactId,
 9    pub user_id_a: UserId,
10    pub user_id_b: UserId,
11    pub a_to_b: bool,
12    pub should_notify: bool,
13    pub accepted: bool,
14}
15
16#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
17pub enum Relation {
18    #[sea_orm(
19        belongs_to = "super::room_participant::Entity",
20        from = "Column::UserIdA",
21        to = "super::room_participant::Column::UserId"
22    )]
23    UserARoomParticipant,
24    #[sea_orm(
25        belongs_to = "super::room_participant::Entity",
26        from = "Column::UserIdB",
27        to = "super::room_participant::Column::UserId"
28    )]
29    UserBRoomParticipant,
30}
31
32impl ActiveModelBehavior for ActiveModel {}