refactor(repo): refresh extras subscription handler
zhenyi committed
Modified lib/repo/handler/extras/subscription.rs lib/repo/handler/extras/subscription.rs +9 −9 View lib/repo/handler/extras/subscription.rs
@@ -1,6 +1,6 @@
1use axum::Json;
21use axum::extract::{Path, State};
3use axum::http::StatusCode;
2use export::data::{AppResponseData, NoData};
3
44use jwt::extractor::AuthUser;
55use uuid::Uuid;
66
@@ -12,15 +12,15 @@
1212 get,
1313 path = "/repo/{channel_id}/{repo_id}/subscription",
1414 tag = "repo",
15 responses((status = 200, description = "Get current user's subscription", body = Subscription)),
15 responses((status = 200, description = "Get current user's subscription", body = AppResponseData<Subscription>)),
1616 security(("bearer_auth" = []))
1717)]
1818pub(crate) async fn get_handler(
1919 State(_svc): State<RepoService>,
2020 AuthUser { claims }: AuthUser,
2121 Path((_, repo_id)): Path<(Uuid, Uuid)>,
22) -> RepoResult<Json<Subscription>> {
23 Ok(Json(Subscription {
22) -> RepoResult<AppResponseData<Subscription>> {
23 Ok(AppResponseData::ok(Subscription {
2424 user_id: claims.sub,
2525 repo_id,
2626 mode: "watch".to_string(),
@@ -39,9 +39,9 @@
3939 State(svc): State<RepoService>,
4040 AuthUser { claims }: AuthUser,
4141 Path((_, repo_id)): Path<(Uuid, Uuid)>,
42) -> RepoResult<StatusCode> {
42) -> RepoResult<AppResponseData<NoData>> {
4343 svc.watch_repo(claims.sub, repo_id).await?;
44 Ok(StatusCode::NO_CONTENT)
44 Ok(AppResponseData::<NoData>::empty())
4545}
4646
4747#[utoipa::path(
@@ -55,7 +55,7 @@
5555 State(svc): State<RepoService>,
5656 AuthUser { claims }: AuthUser,
5757 Path((_, repo_id)): Path<(Uuid, Uuid)>,
58) -> RepoResult<StatusCode> {
58) -> RepoResult<AppResponseData<NoData>> {
5959 svc.unwatch_repo(claims.sub, repo_id).await?;
60 Ok(StatusCode::NO_CONTENT)
60 Ok(AppResponseData::<NoData>::empty())
6161}