add: user stacks
This commit is contained in:
parent
8c3024cb40
commit
75d72460ae
28 changed files with 1028 additions and 9 deletions
|
@ -6,6 +6,7 @@ pub mod oauth;
|
|||
pub mod permissions;
|
||||
pub mod reactions;
|
||||
pub mod requests;
|
||||
pub mod stacks;
|
||||
pub mod uploads;
|
||||
|
||||
#[cfg(feature = "redis")]
|
||||
|
|
|
@ -34,6 +34,7 @@ bitflags! {
|
|||
const MANAGE_MESSAGES = 1 << 23;
|
||||
const MANAGE_UPLOADS = 1 << 24;
|
||||
const MANAGE_EMOJIS = 1 << 25;
|
||||
const MANAGE_STACKS = 1 << 26;
|
||||
|
||||
const _ = !0;
|
||||
}
|
||||
|
|
40
crates/core/src/model/stacks.rs
Normal file
40
crates/core/src/model/stacks.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
use tetratto_shared::{snow::Snowflake, unix_epoch_timestamp};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum StackPrivacy {
|
||||
/// Can be viewed by anyone.
|
||||
Public,
|
||||
/// Can only be viewed by the stack's owner (and users with `MANAGE_STACKS`).
|
||||
Private,
|
||||
}
|
||||
|
||||
impl Default for StackPrivacy {
|
||||
fn default() -> Self {
|
||||
Self::Private
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct UserStack {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
pub owner: usize,
|
||||
pub name: String,
|
||||
pub users: Vec<usize>,
|
||||
pub privacy: StackPrivacy,
|
||||
}
|
||||
|
||||
impl UserStack {
|
||||
/// Create a new [`UserStack`].
|
||||
pub fn new(name: String, owner: usize, users: Vec<usize>) -> Self {
|
||||
Self {
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
owner,
|
||||
name,
|
||||
users,
|
||||
privacy: StackPrivacy::default(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue