tetratto/crates/core/src/model/reactions.rs

35 lines
837 B
Rust
Raw Normal View History

2025-03-24 22:42:33 -04:00
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,
}
}
}