Skip to content
Clone

feat(issues): add issue_attachment delete handler

zhenyi committed
parent 32f42f2 commit 52b9709 Browse files

1 file changed

+27 −0

Added lib/issues/handler/issue_attachment/delete.rs View lib/issues/handler/issue_attachment/delete.rs
@@ -0,0 +1,27 @@
1use axum::extract::{Path, State};
2use axum::http::StatusCode;
3use jwt::extractor::AuthUser;
4use uuid::Uuid;
5
6use crate::error::{IssueError, IssueResult};
7use crate::features::IssueService;
8use crate::features::issue_attachment::owner_type_from_str;
9
10#[utoipa::path(
11 delete,
12 path = "/issues/{channel_id}/attachments/{owner_type}/{owner_id}/{att_id}",
13 tag = "issues",
14 responses((status = 204, description = "Delete attachment")),
15 security(("bearer_auth" = []))
16)]
17pub(crate) async fn handler(
18 State(svc): State<IssueService>,
19 AuthUser { claims }: AuthUser,
20 Path((channel_id, owner_type, owner_id, att_id)): Path<(Uuid, String, Uuid, Uuid)>,
21) -> IssueResult<StatusCode> {
22 let owner_type = owner_type_from_str(&owner_type)
23 .ok_or_else(|| IssueError::BadRequest(format!("invalid owner_type {owner_type}")))?;
24 svc.delete_attachment(claims.sub, channel_id, owner_type, owner_id, att_id)
25 .await?;
26 Ok(StatusCode::NO_CONTENT)
27}
No newline at end of file