feat: Add public album routes and enhance authorization checks for media and albums

This commit is contained in:
2025-11-15 17:18:14 +01:00
parent 199544d1c3
commit a9805b5eb1
16 changed files with 323 additions and 92 deletions

View File

@@ -1,4 +1,6 @@
use libertas_core::models::{Album, AlbumPermission, FaceRegion, Media, MediaMetadata, Person, PersonPermission, Tag};
use libertas_core::models::{
Album, AlbumPermission, FaceRegion, Media, MediaMetadata, Person, PersonPermission, Tag,
};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
@@ -20,7 +22,7 @@ impl From<Media> for MediaResponse {
original_filename: media.original_filename,
mime_type: media.mime_type,
hash: media.hash,
thumbnail_path: media.thumbnail_path,
thumbnail_path: media.thumbnail_path,
}
}
}
@@ -31,7 +33,8 @@ pub struct ListMediaParams {
pub order: Option<String>,
pub mime_type: Option<String>,
#[serde(default)]
pub metadata: Vec<String>,}
pub metadata: Vec<String>,
}
#[derive(Deserialize)]
pub struct CreateAlbumRequest {
@@ -144,7 +147,10 @@ pub struct TagResponse {
impl From<Tag> for TagResponse {
fn from(tag: Tag) -> Self {
Self { id: tag.id, name: tag.name }
Self {
id: tag.id,
name: tag.name,
}
}
}
@@ -162,7 +168,11 @@ pub struct PersonResponse {
impl From<Person> for PersonResponse {
fn from(person: Person) -> Self {
Self { id: person.id, owner_id: person.owner_id, name: person.name }
Self {
id: person.id,
owner_id: person.owner_id,
name: person.name,
}
}
}
@@ -210,4 +220,10 @@ pub struct AssignFaceRequest {
pub struct SharePersonRequest {
pub target_user_id: Uuid,
pub permission: PersonPermission,
}
}
#[derive(Serialize)]
pub struct PublicAlbumBundleResponse {
pub album: AlbumResponse,
pub media: Vec<MediaResponse>,
}