use actix_web::{HttpResponse, web}; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::models::users::UserPresence; use crate::service::AppService; use crate::session::Session; /// Get user presence /// /// Returns the current presence status for the authenticated user, /// including online/offline status, custom status text, and device information. /// Requires authentication. #[utoipa::path( get, path = "/api/v1/user/presence", tag = "User", operation_id = "userGetPresence", responses( (status = 200, description = "Presence retrieved successfully.", body = ApiResponse), (status = 401, description = "Authentication required or session expired", body = ApiErrorResponse), (status = 404, description = "Presence not found for this user", body = ApiErrorResponse), (status = 500, description = "Internal server error", body = ApiErrorResponse), ), security( ("session_cookie" = []) ) )] pub async fn get_presence( service: web::Data, session: Session, ) -> Result { let presence = service.user.user_presence_get(&session).await?; Ok(HttpResponse::Ok().json(ApiResponse::new(presence))) }