add: letters api
This commit is contained in:
parent
46e38042ce
commit
2e60cbc464
9 changed files with 247 additions and 31 deletions
|
@ -17,10 +17,10 @@ default = ["database", "types", "sdk"]
|
|||
[dependencies]
|
||||
pathbufd = "0.1.4"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
toml = "0.9.2"
|
||||
toml = "0.9.4"
|
||||
tetratto-shared = { version = "12.0.6", path = "../shared" }
|
||||
tetratto-l10n = { version = "12.0.0", path = "../l10n" }
|
||||
serde_json = "1.0.141"
|
||||
serde_json = "1.0.142"
|
||||
totp-rs = { version = "5.7.0", features = ["qr", "gen_secret"], optional = true }
|
||||
reqwest = { version = "0.12.22", features = ["json", "multipart"], optional = true }
|
||||
bitflags = { version = "2.9.1", optional = true }
|
||||
|
@ -28,11 +28,11 @@ async-recursion = { version = "1.1.1", optional = true }
|
|||
md-5 = { version = "0.10.6", optional = true }
|
||||
base16ct = { version = "0.2.0", features = ["alloc"], optional = true }
|
||||
base64 = { version = "0.22.1", optional = true }
|
||||
emojis = "0.7.0"
|
||||
emojis = "0.7.1"
|
||||
regex = "1.11.1"
|
||||
oiseau = { version = "0.1.2", default-features = false, features = [
|
||||
"postgres",
|
||||
"redis",
|
||||
], optional = true }
|
||||
paste = { version = "1.0.15", optional = true }
|
||||
tokio = { version = "1.46.1", features = ["macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.47.1", features = ["macros", "rt-multi-thread"] }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
use tetratto_shared::{snow::Snowflake, unix_epoch_timestamp};
|
||||
use crate::model::auth::User;
|
||||
|
||||
/// A letter is the most basic structure of the mail system. Letters are sent
|
||||
/// and received by users.
|
||||
|
@ -41,4 +42,9 @@ impl Letter {
|
|||
replying_to,
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the given user can read the letter.
|
||||
pub fn can_read(&self, user: &User) -> bool {
|
||||
(user.id == self.owner) | self.receivers.contains(&user.id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ pub enum AppScope {
|
|||
UserReadServices,
|
||||
/// Read the user's products.
|
||||
UserReadProducts,
|
||||
/// Read the user's letters.
|
||||
UserReadLetters,
|
||||
/// Create posts as the user.
|
||||
UserCreatePosts,
|
||||
/// Create messages as the user.
|
||||
|
@ -102,6 +104,8 @@ pub enum AppScope {
|
|||
UserCreateServices,
|
||||
/// Create products on behalf of the user.
|
||||
UserCreateProducts,
|
||||
/// Create letters on behalf of the user.
|
||||
UserCreateLetters,
|
||||
/// Delete posts owned by the user.
|
||||
UserDeletePosts,
|
||||
/// Delete messages owned by the user.
|
||||
|
@ -146,6 +150,8 @@ pub enum AppScope {
|
|||
UserManageProducts,
|
||||
/// Manage the user's channel mutes.
|
||||
UserManageChannelMutes,
|
||||
/// Manage the user's letters.
|
||||
UserManageLetters,
|
||||
/// Edit posts created by the user.
|
||||
UserEditPosts,
|
||||
/// Edit drafts created by the user.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue