@@ -10,12 +10,5 @@ bytes = "1.10.1"
|
||||
chrono = "0.4.42"
|
||||
futures = "0.3.31"
|
||||
thiserror = "2.0.17"
|
||||
uuid = "1.18.1"
|
||||
sqlx = { version = "0.8.6", features = [
|
||||
"runtime-tokio",
|
||||
"postgres",
|
||||
"uuid",
|
||||
"chrono",
|
||||
"sqlite",
|
||||
] }
|
||||
uuid = {version = "1.18.1", features = ["v4", "serde"] }
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
|
||||
@@ -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