add: letters api
This commit is contained in:
parent
46e38042ce
commit
2e60cbc464
9 changed files with 247 additions and 31 deletions
|
@ -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