refactor: move business logic out of presentation — ReadAssetFile, checksum, auth checks, MetadataValue conversions

This commit is contained in:
2026-05-31 06:10:07 +02:00
parent 0f003a3bd6
commit 34b231a8f6
18 changed files with 256 additions and 43 deletions

View File

@@ -32,6 +32,10 @@ impl ManageAlbumEntriesHandler {
.await?
.ok_or_else(|| DomainError::NotFound(format!("Album {} not found", cmd.album_id)))?;
if album.creator_user_id != cmd.user_id {
return Err(DomainError::Forbidden("Access denied".to_string()));
}
match cmd.action {
AlbumAction::Add { asset_id } => album.add_asset(asset_id, cmd.user_id)?,
AlbumAction::Remove { asset_id } => album.remove_asset(&asset_id)?,

View File

@@ -6,6 +6,7 @@ use std::sync::Arc;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GetAlbumQuery {
pub album_id: SystemId,
pub user_id: SystemId,
}
pub struct GetAlbumHandler {
@@ -18,9 +19,16 @@ impl GetAlbumHandler {
}
pub async fn execute(&self, query: GetAlbumQuery) -> Result<Album, DomainError> {
self.album_repo
let album = self
.album_repo
.find_by_id(&query.album_id)
.await?
.ok_or_else(|| DomainError::NotFound(format!("Album {} not found", query.album_id)))
.ok_or_else(|| DomainError::NotFound(format!("Album {} not found", query.album_id)))?;
if album.creator_user_id != query.user_id {
return Err(DomainError::Forbidden("Access denied".to_string()));
}
Ok(album)
}
}