add: layouts api
This commit is contained in:
parent
c83d0a9fc0
commit
b493b2ade8
10 changed files with 353 additions and 22 deletions
|
@ -1,5 +1,6 @@
|
|||
use std::{collections::HashMap, fmt::Display};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tetratto_shared::{snow::Snowflake, unix_epoch_timestamp};
|
||||
use crate::model::auth::DefaultTimelineChoice;
|
||||
|
||||
/// Each different page which can be customized.
|
||||
|
@ -20,10 +21,26 @@ pub struct Layout {
|
|||
pub title: String,
|
||||
pub privacy: LayoutPrivacy,
|
||||
pub pages: Vec<LayoutPage>,
|
||||
pub replaces: CustomizablePage,
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
/// Create a new [`Layout`].
|
||||
pub fn new(title: String, owner: usize, replaces: CustomizablePage) -> Self {
|
||||
Self {
|
||||
id: Snowflake::new().to_string().parse::<usize>().unwrap(),
|
||||
created: unix_epoch_timestamp(),
|
||||
owner,
|
||||
title,
|
||||
privacy: LayoutPrivacy::Public,
|
||||
pages: Vec::new(),
|
||||
replaces,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The privacy of the layout, which controls who has the ability to view it.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum LayoutPrivacy {
|
||||
Public,
|
||||
Private,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue