add: reactions
This commit is contained in:
parent
c46eb3b807
commit
382e3bc7a6
18 changed files with 357 additions and 11 deletions
34
crates/core/src/model/reactions.rs
Normal file
34
crates/core/src/model/reactions.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tetratto_shared::{snow::AlmostSnowflake, unix_epoch_timestamp};
|
||||
|
||||
/// All of the items which support reactions.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum AssetType {
|
||||
JournalPage,
|
||||
JournalEntry,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Reaction {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
pub owner: usize,
|
||||
pub asset: usize,
|
||||
pub asset_type: AssetType,
|
||||
}
|
||||
|
||||
impl Reaction {
|
||||
/// Create a new [`Reaction`].
|
||||
pub fn new(owner: usize, asset: usize, asset_type: AssetType) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
.parse::<usize>()
|
||||
.unwrap(),
|
||||
created: unix_epoch_timestamp() as usize,
|
||||
owner,
|
||||
asset,
|
||||
asset_type,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue