tetratto_core/model/
moderation.rs

1use serde::{Deserialize, Serialize};
2use tetratto_shared::{snow::Snowflake, unix_epoch_timestamp};
3
4use super::reactions::AssetType;
5
6#[derive(Serialize, Deserialize)]
7pub struct AuditLogEntry {
8    pub id: usize,
9    pub created: usize,
10    pub moderator: usize,
11    pub content: String,
12}
13
14impl AuditLogEntry {
15    /// Create a new [`AuditLogEntry`].
16    pub fn new(moderator: usize, content: String) -> Self {
17        Self {
18            id: Snowflake::new().to_string().parse::<usize>().unwrap(),
19            created: unix_epoch_timestamp(),
20            moderator,
21            content,
22        }
23    }
24}
25
26#[derive(Serialize, Deserialize)]
27pub struct Report {
28    pub id: usize,
29    pub created: usize,
30    pub owner: usize,
31    pub content: String,
32    pub asset: usize,
33    pub asset_type: AssetType,
34}
35
36impl Report {
37    /// Create a new [`Report`].
38    pub fn new(owner: usize, content: String, asset: usize, asset_type: AssetType) -> Self {
39        Self {
40            id: Snowflake::new().to_string().parse::<usize>().unwrap(),
41            created: unix_epoch_timestamp(),
42            owner,
43            content,
44            asset,
45            asset_type,
46        }
47    }
48}