use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "users")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(unique)]
pub username: String,
#[sea_orm(unique)]
pub email: String,
pub password_hash: String,
pub is_active: bool,
/// Staff/admin: can manage categories and (later) moderate.
pub is_staff: bool,
/// Preferred topic-list sort (latest|top|bottom|hot), applied forum-wide.
pub preferred_sort: String,
/// Profile "Layout": `classic` or `focus` (`list` = classic, legacy).
pub preferred_view: String,
/// Receive a notification when someone reacts to your post.
pub reaction_notifications: bool,
/// Discourse-style trust level 0–4 (New/Basic/Member/Regular/Leader).
pub trust_level: i32,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub last_login_at: Option<DateTimeWithTimeZone>,
/// When the current email address was verified (None = unverified: the
/// account can read but not post, react, bookmark or tag).
pub email_verified_at: Option<DateTimeWithTimeZone>,
/// Uploaded avatar image bytes (None = use the generated letter avatar).
/// `avatar_data` is skipped from serde so the bytes never bloat template
/// contexts; `avatar_content_type` is serialized so templates can tell
/// whether to show the uploaded image or the themed letter avatar.
#[serde(skip)]
pub avatar_data: Option<Vec<u8>>,
pub avatar_content_type: Option<String>,
/// Silenced: can read, can't post, reply, react or flag. Active while
/// `silenced_at` is set and `silenced_until` is absent or ahead.
pub silenced_at: Option<DateTimeWithTimeZone>,
pub silenced_until: Option<DateTimeWithTimeZone>,
pub silence_reason: Option<String>,
/// Suspended: can't sign in. Same shape as the silence.
pub suspended_at: Option<DateTimeWithTimeZone>,
pub suspended_until: Option<DateTimeWithTimeZone>,
pub suspend_reason: Option<String>,
/// Flag shadowban: this user's flags are recorded but don't count and
/// don't surface in the queue. Staff only; never serialized.
#[serde(skip)]
pub flags_ignored_at: Option<DateTimeWithTimeZone>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::user_sessions::Entity")]
UserSessions,
}
impl Related<super::user_sessions::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserSessions.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
2.7 KiB · text
History
263b40b