gitdataai/libs/transport/event/ban.rs

51 lines
1.2 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use models::{ProjectId, UserId};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum BanEventType {
Banned,
Unbanned,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum BanEvent {
Banned(BannedService),
Unbanned(UnbannedService),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BannedService {
pub project: ProjectId,
pub user: UserId,
pub banned_by: UserId,
pub reason: Option<String>,
pub expires_at: Option<DateTime<Utc>>,
pub banned_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UnbannedService {
pub project: ProjectId,
pub user: UserId,
pub unbanned_by: UserId,
pub unbanned_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct BanCreateClient {
pub project: ProjectId,
pub user_id: UserId,
pub reason: Option<String>,
pub expires_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct BanRemoveClient {
pub project: ProjectId,
pub user_id: UserId,
}