add: journals base
add: avatar/banner upload endpoints
This commit is contained in:
parent
b3cac5f97a
commit
bb682add85
14 changed files with 323 additions and 22 deletions
|
@ -1,3 +1,4 @@
|
|||
use super::permissions::FinePermission;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tetratto_shared::{
|
||||
hash::{hash_salted, salt},
|
||||
|
@ -5,8 +6,6 @@ use tetratto_shared::{
|
|||
unix_epoch_timestamp,
|
||||
};
|
||||
|
||||
use super::permissions::FinePermission;
|
||||
|
||||
/// `(ip, token, creation timestamp)`
|
||||
pub type Token = (String, String, usize);
|
||||
|
||||
|
|
52
crates/core/src/model/journal.rs
Normal file
52
crates/core/src/model/journal.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct JournalPage {
|
||||
pub id: usize,
|
||||
pub created: usize,
|
||||
pub title: String,
|
||||
pub prompt: String,
|
||||
/// The ID of the owner of the journal page.
|
||||
pub owner: usize,
|
||||
/// Who can read the journal page.
|
||||
pub read_access: JournalPageReadAccess,
|
||||
/// Who can write to the journal page (create journal entries belonging to it).
|
||||
///
|
||||
/// The owner of the journal page (and moderators) are the ***only*** people
|
||||
/// capable of removing entries.
|
||||
pub write_access: JournalPageWriteAccess,
|
||||
}
|
||||
|
||||
/// Who can read a [`JournalPage`].
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum JournalPageReadAccess {
|
||||
/// Everybody can view the journal page from the owner's profile.
|
||||
Everybody,
|
||||
/// Only people with the link to the journal page.
|
||||
Unlisted,
|
||||
/// Only the owner of the journal page.
|
||||
Private,
|
||||
}
|
||||
|
||||
impl Default for JournalPageReadAccess {
|
||||
fn default() -> Self {
|
||||
Self::Everybody
|
||||
}
|
||||
}
|
||||
|
||||
/// Who can write to a [`JournalPage`].
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum JournalPageWriteAccess {
|
||||
/// Everybody (authenticated + anonymous users).
|
||||
Everybody,
|
||||
/// Authenticated users only.
|
||||
Authenticated,
|
||||
/// Only the owner of the journal page.
|
||||
Owner,
|
||||
}
|
||||
|
||||
impl Default for JournalPageWriteAccess {
|
||||
fn default() -> Self {
|
||||
Self::Authenticated
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
pub mod auth;
|
||||
pub mod journal;
|
||||
pub mod permissions;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -14,8 +16,10 @@ where
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
MiscError(String),
|
||||
DatabaseConnection(String),
|
||||
UserNotFound,
|
||||
GeneralNotFound(String),
|
||||
RegistrationDisabled,
|
||||
DatabaseError(String),
|
||||
IncorrectPassword,
|
||||
|
@ -29,9 +33,11 @@ pub enum Error {
|
|||
impl ToString for Error {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
Self::MiscError(msg) => msg.to_owned(),
|
||||
Self::DatabaseConnection(msg) => msg.to_owned(),
|
||||
Self::DatabaseError(msg) => format!("Database error: {msg}"),
|
||||
Self::UserNotFound => "Unable to find user with given parameters".to_string(),
|
||||
Self::GeneralNotFound(name) => format!("Unable to find requested {name}"),
|
||||
Self::RegistrationDisabled => "Registration is disabled".to_string(),
|
||||
Self::IncorrectPassword => "The given password is invalid".to_string(),
|
||||
Self::NotAllowed => "You are not allowed to do this".to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue