d5939db
use axum::Json;
use axum::extract::State;
use jwt::extractor::AuthUser;
use serde::Serialize;
use crate::error::UserResult;
use crate::features::UserService;
#[derive(Serialize, utoipa::ToSchema)]
pub struct MarkAllReadResp {
pub marked: u64,
}
#[utoipa::path(
post,
path = "/user/me/notifications/mark-all-read",
tag = "user",
responses(
(status = 200, description = "All notifications marked as read.", body = MarkAllReadResp),
),
security(("bearer_auth" = [])),
)]
pub(crate) async fn handler(
State(svc): State<UserService>,
AuthUser { claims }: AuthUser,
) -> UserResult<Json<MarkAllReadResp>> {
let marked = svc.mark_all_notifications_read(claims.sub).await?;
Ok(Json(MarkAllReadResp { marked }))
}