Skip to content
Clone

refactor(user): refresh push_subscriptions upsert handler

zhenyi committed
parent a7c462e commit 9630e02 Browse files

1 file changed

+6 −6

Modified lib/user/handler/security/push_subscriptions/upsert.rs View lib/user/handler/security/push_subscriptions/upsert.rs
@@ -1,5 +1,5 @@
1use axum::Json;
21use axum::extract::State;
2use export::data::{AppRequest, AppRequestData, AppResponseData};
33use jwt::extractor::AuthUser;
44
55use crate::error::UserResult;
@@ -10,16 +10,16 @@
1010 post,
1111 path = "/user/me/push-subscriptions",
1212 tag = "user",
13 request_body = UpsertPushCmd,
13 request_body = AppRequestData<UpsertPushCmd>,
1414 responses(
15 (status = 200, description = "Push subscription upserted (endpoint-keyed).", body = PushSubscriptionView),
15 (status = 200, description = "Push subscription upserted (endpoint-keyed).", body = AppResponseData<PushSubscriptionView>),
1616 ),
1717 security(("bearer_auth" = [])),
1818)]
1919pub(crate) async fn handler(
2020 State(svc): State<UserService>,
2121 AuthUser { claims }: AuthUser,
22 Json(cmd): Json<UpsertPushCmd>,
23) -> UserResult<Json<PushSubscriptionView>> {
24 Ok(Json(svc.upsert_push_subscription(claims.sub, cmd).await?))
22 cmd: AppRequest<UpsertPushCmd>,
23) -> UserResult<AppResponseData<PushSubscriptionView>> {
24 Ok(AppResponseData::ok(svc.upsert_push_subscription(claims.sub, cmd.into_inner()).await?))
2525}
No newline at end of file