use crate::{ApiResponse, error::ApiError}; use actix_web::{HttpResponse, Result, web}; use service::AppService; use session::Session; #[utoipa::path( get, path = "/api/users/me/notifications/preferences", responses( (status = 200, description = "Get notification preferences", body = ApiResponse), (status = 401, description = "Unauthorized"), ), tag = "User" )] pub async fn get_notification_preferences( service: web::Data, session: Session, ) -> Result { let resp = service.user_get_notification_preferences(&session).await?; Ok(ApiResponse::ok(resp).to_response()) } #[utoipa::path( patch, path = "/api/users/me/notifications/preferences", request_body = service::user::notification::NotificationPreferencesParams, responses( (status = 200, description = "Update notification preferences", body = ApiResponse), (status = 401, description = "Unauthorized"), ), tag = "User" )] pub async fn update_notification_preferences( service: web::Data, session: Session, body: web::Json, ) -> Result { let resp = service .user_update_notification_preferences(&session, body.into_inner()) .await?; Ok(ApiResponse::ok(resp).to_response()) }