feat: Implement person management features

- Added hooks for listing, creating, updating, deleting, sharing, and merging people.
- Introduced a new route for person details and media.
- Implemented clustering faces functionality.
- Created services for person-related API interactions.

feat: Introduce tag management functionality

- Added hooks for listing, adding, and removing tags from media.
- Created services for tag-related API interactions.

feat: Enhance user authentication handling

- Added a hook to fetch current user details.
- Updated auth storage to manage user state more effectively.

feat: Update album management features

- Enhanced album service to return created album details.
- Updated API handlers to return album responses upon creation.
- Modified album repository to return created album.

feat: Implement media management improvements

- Added media details fetching and processing of media URLs.
- Enhanced media upload functionality to return processed media.

feat: Introduce face management features

- Added services for listing faces for media and assigning faces to persons.

fix: Update API client to clear authentication state on 401 errors.
This commit is contained in:
2025-11-16 02:24:50 +01:00
parent f41a3169e9
commit 94b184d3b0
34 changed files with 1300 additions and 281 deletions

View File

@@ -2,6 +2,7 @@ use axum::{
Json, Router,
extract::{Path, State},
http::StatusCode,
response::IntoResponse,
routing::{get, post, put},
};
use libertas_core::schema::{
@@ -24,7 +25,7 @@ async fn create_album(
State(state): State<AppState>,
UserId(user_id): UserId,
Json(payload): Json<CreateAlbumRequest>,
) -> Result<StatusCode, ApiError> {
) -> Result<impl IntoResponse, ApiError> {
let album_data = CreateAlbumData {
owner_id: user_id,
name: &payload.name,
@@ -32,9 +33,9 @@ async fn create_album(
is_public: payload.is_public.unwrap_or(false),
};
state.album_service.create_album(album_data).await?;
Ok(StatusCode::CREATED)
let album = state.album_service.create_album(album_data).await?;
let album_response = AlbumResponse::from(album);
Ok((StatusCode::CREATED, Json(album_response)))
}
async fn add_media_to_album(

View File

@@ -1,8 +1,11 @@
use axum::{Json, extract::State, http::StatusCode};
use libertas_core::schema::{CreateUserData, LoginUserData};
use crate::{error::ApiError, schema::{LoginRequest, LoginResponse, RegisterRequest, UserResponse}, state::AppState};
use crate::{
error::ApiError,
schema::{LoginRequest, LoginResponse, RegisterRequest, UserResponse},
state::AppState,
};
pub async fn register(
State(state): State<AppState>,
@@ -20,6 +23,8 @@ pub async fn register(
id: user.id,
username: user.username,
email: user.email,
storage_used: user.storage_used,
storage_quota: user.storage_quota,
};
Ok((StatusCode::CREATED, Json(response)))

View File

@@ -12,6 +12,8 @@ pub async fn get_me(
id: user.id,
username: user.username,
email: user.email,
storage_used: user.storage_used,
storage_quota: user.storage_quota,
};
Ok(Json(response))
}

View File

@@ -116,6 +116,8 @@ pub struct UserResponse {
pub id: Uuid,
pub username: String,
pub email: String,
pub storage_used: i64,
pub storage_quota: i64,
}
#[derive(Serialize)]

View File

@@ -34,7 +34,7 @@ impl AlbumServiceImpl {
#[async_trait]
impl AlbumService for AlbumServiceImpl {
async fn create_album(&self, data: CreateAlbumData<'_>) -> CoreResult<()> {
async fn create_album(&self, data: CreateAlbumData<'_>) -> CoreResult<Album> {
if data.name.is_empty() {
return Err(CoreError::Validation(
"Album name cannot be empty".to_string(),