@@ -20,4 +20,5 @@ pub struct Config {
|
||||
pub media_library_path: String,
|
||||
pub broker_url: String,
|
||||
pub max_upload_size_mb: Option<u32>,
|
||||
pub default_storage_quota_gb: Option<u64>,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
#[sqlx(type_name = "TEXT")]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
||||
pub enum Role {
|
||||
User,
|
||||
Admin,
|
||||
@@ -17,6 +16,15 @@ impl Role {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Role {
|
||||
fn from(s: &str) -> Self {
|
||||
match s {
|
||||
"admin" => Role::Admin,
|
||||
_ => Role::User,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Media {
|
||||
pub id: uuid::Uuid,
|
||||
pub owner_id: uuid::Uuid,
|
||||
@@ -30,7 +38,7 @@ pub struct Media {
|
||||
pub height: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, sqlx::FromRow)]
|
||||
#[derive(Clone)]
|
||||
pub struct User {
|
||||
pub id: uuid::Uuid,
|
||||
pub username: String,
|
||||
@@ -44,7 +52,7 @@ pub struct User {
|
||||
pub storage_used: i64, // in bytes
|
||||
}
|
||||
|
||||
#[derive(Clone, sqlx::FromRow)]
|
||||
#[derive(Clone)]
|
||||
pub struct Album {
|
||||
pub id: uuid::Uuid,
|
||||
pub owner_id: uuid::Uuid,
|
||||
@@ -78,14 +86,30 @@ pub struct AlbumMedia {
|
||||
pub media_id: uuid::Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, sqlx::Type, PartialEq, Eq, Deserialize)]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
#[sqlx(type_name = "album_permission")]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
|
||||
pub enum AlbumPermission {
|
||||
View,
|
||||
Contribute,
|
||||
}
|
||||
|
||||
impl AlbumPermission {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
AlbumPermission::View => "view",
|
||||
AlbumPermission::Contribute => "contribute",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for AlbumPermission {
|
||||
fn from(s: &str) -> Self {
|
||||
match s {
|
||||
"contribute" => AlbumPermission::Contribute,
|
||||
_ => AlbumPermission::View,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AlbumShare {
|
||||
pub album_id: uuid::Uuid,
|
||||
pub user_id: uuid::Uuid,
|
||||
|
||||
Reference in New Issue
Block a user