use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

/// 滥用检测规则
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "abuse_rules")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    pub name: String,
    /// domain_emails_10min | ip_connects_1min | ...
    pub metric: String,
    pub window_seconds: i64,
    pub threshold: i64,
    /// auto_block_sender | auto_block_ip | alert | quarantine
    pub action: String,
    pub block_ttl_seconds: i64,
    pub enabled: bool,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

#[async_trait::async_trait]
impl ActiveModelBehavior for ActiveModel {}
