Skip to content
Clone

refactor(issues): refresh issue_attachment upload handler

zhenyi committed
parent 560bb6e commit 50169cd Browse files

1 file changed

+7 −8

Modified lib/issues/handler/issue_attachment/upload.rs View lib/issues/handler/issue_attachment/upload.rs
@@ -1,6 +1,5 @@
1use axum::Json;
21use axum::extract::{Path, State};
3use axum::http::StatusCode;
2use export::data::{AppRequest, AppRequestData, AppResponseData};
43use jwt::extractor::AuthUser;
54use uuid::Uuid;
65
@@ -12,20 +11,20 @@
1211 post,
1312 path = "/issues/{channel_id}/attachments/{owner_type}/{owner_id}",
1413 tag = "issues",
15 request_body = UploadAttachmentInput,
16 responses((status = 201, description = "Upload attachment", body = AttachmentView)),
14 request_body = AppRequestData<UploadAttachmentInput>,
15 responses((status = 201, description = "Upload attachment", body = AppResponseData<AttachmentView>)),
1716 security(("bearer_auth" = []))
1817)]
1918pub(crate) async fn handler(
2019 State(svc): State<IssueService>,
2120 AuthUser { claims }: AuthUser,
2221 Path((channel_id, owner_type, owner_id)): Path<(Uuid, String, Uuid)>,
23 Json(input): Json<UploadAttachmentInput>,
24) -> IssueResult<(StatusCode, Json<AttachmentView>)> {
22 input: AppRequest<UploadAttachmentInput>,
23) -> IssueResult<AppResponseData<AttachmentView>> {
2524 let owner_type = owner_type_from_str(&owner_type)
2625 .ok_or_else(|| IssueError::BadRequest(format!("invalid owner_type {owner_type}")))?;
2726 let view = svc
28 .upload_attachment(claims.sub, channel_id, owner_type, owner_id, input)
27 .upload_attachment(claims.sub, channel_id, owner_type, owner_id, input.into_inner())
2928 .await?;
30 Ok((StatusCode::CREATED, Json(view)))
29 Ok(AppResponseData::ok(view).with_code(201))
3130}
No newline at end of file