Skip to content

Commit

Permalink
feat: Add the unregister user route (#195)
Browse files Browse the repository at this point in the history
Closes #179
  • Loading branch information
AzureMarker authored Jul 28, 2020
1 parent 5b23dbb commit b4bb163
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions autoendpoint/src/routes/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ pub async fn register_uaid_route(
})))
}

/// Handle the `DELETE /v1/{router_type}/{app_id}/registration/{uaid}` route
pub async fn unregister_user_route(
_auth: AuthorizationCheck,
path_args: RegistrationPathArgsWithUaid,
state: Data<ServerState>,
) -> ApiResult<HttpResponse> {
debug!("Unregistering UAID {}", path_args.uaid);
state.ddb.remove_user(path_args.uaid).await?;
Ok(HttpResponse::Ok().finish())
}

/// Handle the `PUT /v1/{router_type}/{app_id}/registration/{uaid}` route
pub async fn update_token_route(
_auth: AuthorizationCheck,
Expand Down
5 changes: 3 additions & 2 deletions autoendpoint/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::routers::fcm::router::FcmRouter;
use crate::routes::health::{health_route, lb_heartbeat_route, status_route, version_route};
use crate::routes::registration::{
get_channels_route, new_channel_route, register_uaid_route, unregister_channel_route,
update_token_route,
unregister_user_route, update_token_route,
};
use crate::routes::webpush::{delete_notification_route, webpush_route};
use crate::settings::Settings;
Expand Down Expand Up @@ -104,7 +104,8 @@ impl Server {
.service(
web::resource("/v1/{router_type}/{app_id}/registration/{uaid}")
.route(web::put().to(update_token_route))
.route(web::get().to(get_channels_route)),
.route(web::get().to(get_channels_route))
.route(web::delete().to(unregister_user_route)),
)
.service(
web::resource("/v1/{router_type}/{app_id}/registration/{uaid}/subscription")
Expand Down

0 comments on commit b4bb163

Please sign in to comment.