Skip to content
Clone
f8c6a14
32 lines 1.1 KB Rust
use axum::extract::{Path, State};
use export::data::{AppResponseData, NoData};
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::IssueResult;
use crate::features::IssueService;
#[utoipa::path(
delete,
path = "/issues/{space_name}/{issue_id}/comments/{comment_id}",
tag = "issues",
params(
("space_name" = String, Path),
("issue_id" = Uuid, Path),
("comment_id" = Uuid, Path),
),
responses((status = 204, description = "Delete comment")),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<IssueService>,
AuthUser { claims }: AuthUser,
Path((space_name, issue_id, comment_id)): Path<(String, Uuid, Uuid)>,
) -> IssueResult<AppResponseData<NoData>> {
let space_id = space::features::lookup::lookup_space_by_name(&svc, &space_name).await?;
space::features::authz::require_active_member(&svc, claims.sub, space_id).await?;
let channel_id = crate::features::lookup::channel_for_issue(&svc, issue_id).await?;
svc.delete_comment(claims.sub, channel_id, issue_id, comment_id)
.await?;
Ok(AppResponseData::<NoData>::empty())
}