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, utoipa::ToSchema, )] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum AllowJoinLevel { #[default] #[sea_orm(num_value = 0)] None, #[sea_orm(num_value = 1)] NeedMailActive, #[sea_orm(num_value = 2)] NeedMailActiveAndLastOneMid, #[sea_orm(num_value = 3)] NeedMailActiveAndLastOneHours, #[sea_orm(num_value = 4)] NeedMailActiveAndPhoneActive, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "spaces")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(unique)] pub lower_name: String, pub name: String, pub description: Option, pub owner_id: i64, pub avatar_url: Option, #[sea_orm(default_value = "false")] pub is_private: bool, pub is_active: bool, pub allow_join: bool, pub allow_invite: bool, pub invite_sort_url_hash: Option, pub nums_members: i64, pub banner_url: Option, pub banner_width: Option, pub banner_height: Option, pub invite_banner_url: Option, pub invite_banner_width: Option, pub invite_banner_height: Option, pub embed_splash_url: Option, pub embed_splash_width: Option, pub embed_splash_height: Option, pub welcome_message: Option, pub allow_join_level: AllowJoinLevel, pub member_must_enable_2fa: bool, pub welcome_object: Option, #[sea_orm(default_value = "invite_only")] pub join_policy: String, #[sea_orm(default_value = true)] pub require_email_verified: bool, #[sea_orm(default_value = false)] pub require_mfa: bool, #[sea_orm(default_value = 1)] pub version: i32, pub created_at: OffsetDateTime, pub updated_at: OffsetDateTime, #[sea_orm(belongs_to, from = "owner_id", to = "uid")] pub owner: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}