use crate::AppService; use crate::error::AppError; use serde::{Deserialize, Serialize}; use session::Session; use uuid::Uuid; #[derive(Deserialize, Serialize, Clone, Debug, utoipa::ToSchema)] pub struct ContextMe { pub uid: Uuid, pub username: String, pub display_name: Option, pub avatar_url: Option, pub has_unread_notifications: u64, } impl AppService { pub async fn auth_me(&self, ctx: Session) -> Result { let user_id = ctx.user().ok_or(AppError::Unauthorized)?; let user = self.utils_find_user_by_uid(user_id).await?; // let notify = self.notify_get_user_unread_count(&ctx).await?; Ok(ContextMe { uid: user.uid, username: user.username, display_name: user.display_name, avatar_url: user.avatar_url, // has_unread_notifications: notify, has_unread_notifications: 0, }) } }