use serde::{Serialize, Deserialize};
use tetratto_shared::{snow::Snowflake, unix_epoch_timestamp};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum JournalPrivacyPermission {
Public,
Private,
}
impl Default for JournalPrivacyPermission {
fn default() -> Self {
Self::Private
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Journal {
pub id: usize,
pub created: usize,
pub owner: usize,
pub title: String,
pub privacy: JournalPrivacyPermission,
pub dirs: Vec<(usize, usize, String)>,
}
impl Journal {
pub fn new(owner: usize, title: String) -> Self {
Self {
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
created: unix_epoch_timestamp(),
owner,
title,
privacy: JournalPrivacyPermission::default(),
dirs: Vec::new(),
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Note {
pub id: usize,
pub created: usize,
pub owner: usize,
pub title: String,
pub journal: usize,
pub content: String,
pub edited: usize,
pub dir: usize,
pub tags: Vec<String>,
pub is_global: bool,
}
impl Note {
pub fn new(owner: usize, title: String, journal: usize, content: String) -> Self {
let created = unix_epoch_timestamp();
Self {
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
created,
owner,
title,
journal,
content,
edited: created,
dir: 0,
tags: Vec::new(),
is_global: false,
}
}
}