Skip to content
Clone

feat(issues): add issue_watch upsert handler

zhenyi committed
parent f9f9355 commit 7dce3f0 Browse files

1 file changed

+28 −0

Added lib/issues/handler/issue_watch/upsert.rs View lib/issues/handler/issue_watch/upsert.rs
@@ -0,0 +1,28 @@
1use axum::Json;
2use axum::extract::{Path, State};
3use jwt::extractor::AuthUser;
4use uuid::Uuid;
5
6use crate::error::IssueResult;
7use crate::features::IssueService;
8use crate::features::issue_watch::{UpsertWatchOption, WatchView};
9
10#[utoipa::path(
11 put,
12 path = "/issues/{channel_id}/{issue_id}/watch",
13 tag = "issues",
14 request_body = UpsertWatchOption,
15 responses((status = 200, description = "Upsert watch state", body = WatchView)),
16 security(("bearer_auth" = []))
17)]
18pub(crate) async fn handler(
19 State(svc): State<IssueService>,
20 AuthUser { claims }: AuthUser,
21 Path((channel_id, issue_id)): Path<(Uuid, Uuid)>,
22 Json(input): Json<UpsertWatchOption>,
23) -> IssueResult<Json<WatchView>> {
24 let view = svc
25 .upsert_watch(claims.sub, channel_id, issue_id, input)
26 .await?;
27 Ok(Json(view))
28}
No newline at end of file