feat: Add thumbnail generation feature and update media model
- 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.
This commit is contained in:
@@ -12,6 +12,22 @@ pub struct DatabaseConfig {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ThumbnailFormat {
|
||||
Jpeg,
|
||||
Webp,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct ThumbnailConfig {
|
||||
pub format: ThumbnailFormat,
|
||||
pub quality: u8,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub library_path: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct Config {
|
||||
pub database: DatabaseConfig,
|
||||
@@ -22,4 +38,5 @@ pub struct Config {
|
||||
pub max_upload_size_mb: Option<u32>,
|
||||
pub default_storage_quota_gb: Option<u64>,
|
||||
pub allowed_sort_columns: Option<Vec<String>>,
|
||||
pub thumbnail_config: Option<ThumbnailConfig>,
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ pub struct Media {
|
||||
pub width: Option<i32>,
|
||||
pub height: Option<i32>,
|
||||
pub date_taken: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub thumbnail_path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
||||
@@ -3,9 +3,7 @@ use std::sync::Arc;
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{
|
||||
error::CoreResult,
|
||||
models::Media,
|
||||
repositories::{AlbumRepository, MediaRepository, UserRepository},
|
||||
config::Config, error::CoreResult, models::Media, repositories::{AlbumRepository, MediaRepository, UserRepository}
|
||||
};
|
||||
|
||||
pub struct PluginData {
|
||||
@@ -17,6 +15,7 @@ pub struct PluginContext {
|
||||
pub album_repo: Arc<dyn AlbumRepository>,
|
||||
pub user_repo: Arc<dyn UserRepository>,
|
||||
pub media_library_path: String,
|
||||
pub config: Arc<Config>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
@@ -12,7 +12,7 @@ pub trait MediaRepository: Send + Sync {
|
||||
async fn create(&self, media: &Media) -> CoreResult<()>;
|
||||
async fn find_by_id(&self, id: Uuid) -> CoreResult<Option<Media>>;
|
||||
async fn list_by_user(&self, user_id: Uuid, options: &ListMediaOptions) -> CoreResult<Vec<Media>>;
|
||||
async fn update_metadata(
|
||||
async fn update_exif_data(
|
||||
&self,
|
||||
id: Uuid,
|
||||
width: Option<i32>,
|
||||
@@ -20,6 +20,7 @@ pub trait MediaRepository: Send + Sync {
|
||||
location: Option<String>,
|
||||
date_taken: Option<chrono::DateTime<chrono::Utc>>,
|
||||
) -> CoreResult<()>;
|
||||
async fn update_thumbnail_path(&self, id: Uuid, thumbnail_path: String) -> CoreResult<()>;
|
||||
async fn delete(&self, id: Uuid) -> CoreResult<()>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user