Skip to content
Clone
194c44c
34 lines 1.0 KB Rust
use axum::extract::{Path, State};
use export::rest::{AppResponseData, NoData};
use jwt::Session;
use uuid::Uuid;
use crate::errors::ApiError;
use crate::services::AuthService;
use jwt::share::session::require_uid;
#[utoipa::path(
delete,
path = "/me/notifications/{notification_id}",
tag = "notifications",
description = "删除当前用户名下的指定通知记录。",
params(
("notification_id" = Uuid, Path, description = "notification id")
),
responses(
(status = 200, description = "notification deleted", body = AppResponseData<NoData>),
(status = 401, description = "authentication required", body = AppResponseData<NoData>)
)
)]
pub async fn delete_notification(
State(service): State<AuthService>,
session: Session,
Path(notification_id): Path<Uuid>,
) -> Result<AppResponseData<NoData>, ApiError> {
let uid = require_uid(&session)?;
service
.delete_notification(uid, notification_id)
.await
.map_err(ApiError::from)?;
Ok(AppResponseData::empty())
}