add: mail base
This commit is contained in:
parent
a337e0c7c1
commit
29155ddb0c
11 changed files with 211 additions and 3 deletions
35
crates/core/src/model/mail.rs
Normal file
35
crates/core/src/model/mail.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
use tetratto_shared::{snow::Snowflake, unix_epoch_timestamp};
|
||||
|
||||
/// A letter is the most basic structure of the mail system. Letters are sent
|
||||
/// and received by users.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Letter {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
pub owner: usize,
|
||||
pub receivers: Vec<usize>,
|
||||
pub subject: String,
|
||||
pub content: String,
|
||||
/// The ID of every use who has read the letter. Can be checked in the UI
|
||||
/// with `user.id in letter.read_by`.
|
||||
///
|
||||
/// This field can be updated by anyone in the letter's `receivers` field.
|
||||
/// Other fields in the letter can only be updated by the letter's `owner`.
|
||||
pub read_by: Vec<usize>,
|
||||
}
|
||||
|
||||
impl Letter {
|
||||
/// Create a new [`Letter`].
|
||||
pub fn new(owner: usize, receivers: Vec<usize>, subject: String, content: String) -> Self {
|
||||
Self {
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp(),
|
||||
owner,
|
||||
receivers,
|
||||
subject,
|
||||
content,
|
||||
read_by: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ pub mod communities;
|
|||
pub mod communities_permissions;
|
||||
pub mod journals;
|
||||
pub mod littleweb;
|
||||
pub mod mail;
|
||||
pub mod moderation;
|
||||
pub mod oauth;
|
||||
pub mod permissions;
|
||||
|
|
|
@ -178,6 +178,7 @@ bitflags! {
|
|||
const MANAGE_SERVICES = 1 << 3;
|
||||
const MANAGE_PRODUCTS = 1 << 4;
|
||||
const DEVELOPER_PASS = 1 << 5;
|
||||
const MANAGE_LETTERS = 1 << 6;
|
||||
|
||||
const _ = !0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue