1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add minimum chat moderation to enable bans for #22

This commit is contained in:
NG (Graham)
2025-05-29 20:55:36 -04:00
parent 9d9f8a73fc
commit c441b8b5ef
15 changed files with 467 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ pub mod garage;
pub mod campaign;
pub mod campaign_difficulty_completion;
pub mod common_query;
pub mod sanction;
pub fn parse_int_csv(s: &str) -> Vec<u32> {
s.split(',').filter_map(|i_as_s| {

View File

@@ -0,0 +1,46 @@
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "sanctions")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: u32,
pub user_id: u32,
pub creation_time: i64, // seconds since unix epoch
pub issuer_id: u32,
pub issuer_name: String,
pub descriptor: Descriptor,
pub reason: String,
pub duration: Option<i64>, // seconds after creation_time (null means permanent or irrelevant)
pub acknowledged: Option<i64>, // seconds since unix epoch
pub appealer_id: Option<u32>, // moderator who approved appeal
pub appeal_time: Option<i64>, // seconds since unix epoch
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
to = "super::user::Column::Id"
)]
User,
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)", rename_all = "PascalCase")]
pub enum Descriptor {
Warn,
Mute,
Ban,
Note,
Kick,
}