- Updated workspace members to include `libertas_importer`. - Added a new migration to add `thumbnail_path` column to `media` table. - Enhanced configuration structures to include `thumbnail_config`. - Modified `Media` model to include `thumbnail_path`. - Updated `MediaRepository` trait and its implementation to handle thumbnail path updates. - Created `ThumbnailPlugin` for generating thumbnails based on media configurations. - Integrated thumbnail generation into the media processing workflow. - Updated dependencies in `libertas_worker` and `libertas_importer` for image processing.
120 lines
2.5 KiB
Rust
120 lines
2.5 KiB
Rust
use serde::Deserialize;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
pub enum Role {
|
|
User,
|
|
Admin,
|
|
}
|
|
|
|
impl Role {
|
|
pub fn as_str(&self) -> &'static str {
|
|
match self {
|
|
Role::User => "user",
|
|
Role::Admin => "admin",
|
|
}
|
|
}
|
|
}
|
|
|
|
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,
|
|
pub storage_path: String,
|
|
pub original_filename: String,
|
|
pub mime_type: String,
|
|
pub hash: String,
|
|
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
pub extracted_location: Option<String>,
|
|
pub width: Option<i32>,
|
|
pub height: Option<i32>,
|
|
pub date_taken: Option<chrono::DateTime<chrono::Utc>>,
|
|
pub thumbnail_path: Option<String>,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct User {
|
|
pub id: uuid::Uuid,
|
|
pub username: String,
|
|
pub email: String,
|
|
pub hashed_password: String,
|
|
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
pub updated_at: chrono::DateTime<chrono::Utc>,
|
|
|
|
pub role: Role,
|
|
pub storage_quota: i64, // in bytes
|
|
pub storage_used: i64, // in bytes
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct Album {
|
|
pub id: uuid::Uuid,
|
|
pub owner_id: uuid::Uuid,
|
|
pub name: String,
|
|
pub description: Option<String>,
|
|
pub is_public: bool,
|
|
pub created_at: chrono::DateTime<chrono::Utc>,
|
|
pub updated_at: chrono::DateTime<chrono::Utc>,
|
|
}
|
|
|
|
pub struct Person {
|
|
pub id: uuid::Uuid,
|
|
pub owner_id: uuid::Uuid,
|
|
pub name: String,
|
|
pub thumbnail_media_id: Option<uuid::Uuid>,
|
|
}
|
|
|
|
pub struct FaceRegion {
|
|
pub id: uuid::Uuid,
|
|
pub media_id: uuid::Uuid,
|
|
pub person_id: Option<uuid::Uuid>,
|
|
|
|
pub x_min: f32,
|
|
pub y_min: f32,
|
|
pub x_max: f32,
|
|
pub y_max: f32,
|
|
}
|
|
|
|
pub struct AlbumMedia {
|
|
pub album_id: uuid::Uuid,
|
|
pub media_id: uuid::Uuid,
|
|
}
|
|
|
|
#[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,
|
|
pub permission: AlbumPermission,
|
|
}
|