fix
This commit is contained in:
@@ -8,13 +8,14 @@ use axum::{
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::application::ports::favorites_ports::FavoritesUseCase;
|
||||
use crate::interfaces::middleware::auth::AuthUser;
|
||||
|
||||
/// Handler for favorite-related API endpoints
|
||||
pub async fn get_favorites(
|
||||
State(favorites_service): State<Arc<dyn FavoritesUseCase>>,
|
||||
auth_user: AuthUser,
|
||||
) -> impl IntoResponse {
|
||||
// For demo purposes, we're using a fixed user ID
|
||||
let user_id = "00000000-0000-0000-0000-000000000000";
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
match favorites_service.get_favorites(user_id).await {
|
||||
Ok(favorites) => {
|
||||
@@ -36,10 +37,10 @@ pub async fn get_favorites(
|
||||
/// Add an item to user's favorites
|
||||
pub async fn add_favorite(
|
||||
State(favorites_service): State<Arc<dyn FavoritesUseCase>>,
|
||||
auth_user: AuthUser,
|
||||
Path((item_type, item_id)): Path<(String, String)>,
|
||||
) -> impl IntoResponse {
|
||||
// For demo purposes, we're using a fixed user ID
|
||||
let user_id = "00000000-0000-0000-0000-000000000000";
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
// Validate item_type
|
||||
if item_type != "file" && item_type != "folder" {
|
||||
@@ -76,10 +77,10 @@ pub async fn add_favorite(
|
||||
/// Remove an item from user's favorites
|
||||
pub async fn remove_favorite(
|
||||
State(favorites_service): State<Arc<dyn FavoritesUseCase>>,
|
||||
auth_user: AuthUser,
|
||||
Path((item_type, item_id)): Path<(String, String)>,
|
||||
) -> impl IntoResponse {
|
||||
// For demo purposes, we're using a fixed user ID
|
||||
let user_id = "00000000-0000-0000-0000-000000000000";
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
match favorites_service.remove_from_favorites(user_id, &item_id, &item_type).await {
|
||||
Ok(removed) => {
|
||||
|
||||
@@ -16,6 +16,7 @@ use crate::infrastructure::services::compression_service::{
|
||||
CompressionService, GzipCompressionService, CompressionLevel
|
||||
};
|
||||
use crate::common::di::AppState;
|
||||
use crate::interfaces::middleware::auth::CurrentUserId;
|
||||
|
||||
/**
|
||||
* Type aliases for dependency injection state.
|
||||
@@ -1068,6 +1069,7 @@ impl FileHandler {
|
||||
/// 3. Decrement dedup reference count for the content hash
|
||||
pub async fn delete_file(
|
||||
State(state): State<GlobalState>,
|
||||
CurrentUserId(user_id): CurrentUserId,
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
let dedup_service = &state.core.dedup_service;
|
||||
@@ -1097,12 +1099,12 @@ impl FileHandler {
|
||||
|
||||
// Debug logs to track trash components
|
||||
tracing::debug!("Trash service type: {}", std::any::type_name_of_val(&*trash_service));
|
||||
let default_user_id = "00000000-0000-0000-0000-000000000000".to_string();
|
||||
tracing::info!("Using default user ID: {}", default_user_id);
|
||||
// User ID extracted from authenticated token via CurrentUserId
|
||||
tracing::info!("Using authenticated user ID: {}", user_id);
|
||||
|
||||
// Try to move to trash first - add more detailed logging
|
||||
tracing::info!("About to call trash_service.move_to_trash with id={}, type=file", id);
|
||||
match trash_service.move_to_trash(&id, "file", &default_user_id).await {
|
||||
match trash_service.move_to_trash(&id, "file", &user_id).await {
|
||||
Ok(_) => {
|
||||
tracing::info!("File successfully moved to trash: {}", id);
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ impl FolderHandler {
|
||||
/// Deletes a folder with trash functionality
|
||||
pub async fn delete_folder_with_trash(
|
||||
State(state): State<GlobalAppState>,
|
||||
_auth_user: AuthUser,
|
||||
auth_user: AuthUser,
|
||||
Path(id): Path<String>,
|
||||
) -> impl IntoResponse {
|
||||
// Check if trash service is available
|
||||
@@ -182,7 +182,7 @@ impl FolderHandler {
|
||||
tracing::info!("Moving folder to trash: {}", id);
|
||||
|
||||
// Try to move to trash first
|
||||
match trash_service.move_to_trash(&id, "folder", &"00000000-0000-0000-0000-000000000000".to_string()).await {
|
||||
match trash_service.move_to_trash(&id, "folder", &auth_user.id).await {
|
||||
Ok(_) => {
|
||||
tracing::info!("Folder successfully moved to trash: {}", id);
|
||||
return StatusCode::NO_CONTENT.into_response();
|
||||
|
||||
@@ -9,6 +9,7 @@ use serde::Deserialize;
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::application::ports::recent_ports::RecentItemsUseCase;
|
||||
use crate::interfaces::middleware::auth::AuthUser;
|
||||
|
||||
/// Parámetros de consulta para obtener elementos recientes
|
||||
#[derive(Deserialize)]
|
||||
@@ -20,10 +21,10 @@ pub struct GetRecentParams {
|
||||
/// Obtener elementos recientes del usuario
|
||||
pub async fn get_recent_items(
|
||||
State(recent_service): State<Arc<dyn RecentItemsUseCase>>,
|
||||
auth_user: AuthUser,
|
||||
Query(params): Query<GetRecentParams>,
|
||||
) -> impl IntoResponse {
|
||||
// Para pruebas, usando ID de usuario fijo
|
||||
let user_id = "00000000-0000-0000-0000-000000000000";
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
match recent_service.get_recent_items(user_id, params.limit).await {
|
||||
Ok(items) => {
|
||||
@@ -45,10 +46,10 @@ pub async fn get_recent_items(
|
||||
/// Registrar acceso a un elemento
|
||||
pub async fn record_item_access(
|
||||
State(recent_service): State<Arc<dyn RecentItemsUseCase>>,
|
||||
auth_user: AuthUser,
|
||||
Path((item_type, item_id)): Path<(String, String)>,
|
||||
) -> impl IntoResponse {
|
||||
// Para pruebas, usando ID de usuario fijo
|
||||
let user_id = "00000000-0000-0000-0000-000000000000";
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
// Validar tipo de elemento
|
||||
if item_type != "file" && item_type != "folder" {
|
||||
@@ -85,10 +86,10 @@ pub async fn record_item_access(
|
||||
/// Eliminar un elemento de recientes
|
||||
pub async fn remove_from_recent(
|
||||
State(recent_service): State<Arc<dyn RecentItemsUseCase>>,
|
||||
auth_user: AuthUser,
|
||||
Path((item_type, item_id)): Path<(String, String)>,
|
||||
) -> impl IntoResponse {
|
||||
// Para pruebas, usando ID de usuario fijo
|
||||
let user_id = "00000000-0000-0000-0000-000000000000";
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
match recent_service.remove_from_recent(user_id, &item_id, &item_type).await {
|
||||
Ok(removed) => {
|
||||
@@ -125,9 +126,9 @@ pub async fn remove_from_recent(
|
||||
/// Limpiar todos los elementos recientes
|
||||
pub async fn clear_recent_items(
|
||||
State(recent_service): State<Arc<dyn RecentItemsUseCase>>,
|
||||
auth_user: AuthUser,
|
||||
) -> impl IntoResponse {
|
||||
// Para pruebas, usando ID de usuario fijo
|
||||
let user_id = "00000000-0000-0000-0000-000000000000";
|
||||
let user_id = &auth_user.id;
|
||||
|
||||
match recent_service.clear_recent_items(user_id).await {
|
||||
Ok(_) => {
|
||||
|
||||
Reference in New Issue
Block a user