Skip to content

Commit

Permalink
Add the get channels route (#191)
Browse files Browse the repository at this point in the history
Closes #181
  • Loading branch information
AzureMarker authored Jul 28, 2020
1 parent 6cc9a7d commit 8c4f23b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions autoendpoint/src/routes/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ pub async fn new_channel_route(
})))
}

/// Handle the `GET /v1/{router_type}/{app_id}/registration/{uaid}` route
pub async fn get_channels_route(
_auth: AuthorizationCheck,
path_args: RegistrationPathArgsWithUaid,
state: Data<ServerState>,
) -> ApiResult<HttpResponse> {
debug!("Getting channel IDs for UAID {}", path_args.uaid);
let channel_ids = state.ddb.get_channels(path_args.uaid).await?;

Ok(HttpResponse::Ok().json(serde_json::json!({
"uaid": path_args.uaid,
"channelIDs": channel_ids
})))
}

/// Increment a metric with data from the request
fn incr_metric(name: &str, metrics: &StatsdClient, request: &HttpRequest) {
metrics
Expand Down
7 changes: 5 additions & 2 deletions autoendpoint/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use crate::metrics;
use crate::middleware::sentry::sentry_middleware;
use crate::routers::fcm::router::FcmRouter;
use crate::routes::health::{health_route, lb_heartbeat_route, status_route, version_route};
use crate::routes::registration::{new_channel_route, register_uaid_route, update_token_route};
use crate::routes::registration::{
get_channels_route, new_channel_route, register_uaid_route, update_token_route,
};
use crate::routes::webpush::{delete_notification_route, webpush_route};
use crate::settings::Settings;
use actix_cors::Cors;
Expand Down Expand Up @@ -88,7 +90,8 @@ impl Server {
)
.service(
web::resource("/v1/{router_type}/{app_id}/registration/{uaid}")
.route(web::put().to(update_token_route)),
.route(web::put().to(update_token_route))
.route(web::get().to(get_channels_route)),
)
.service(
web::resource("/v1/{router_type}/{app_id}/registration/{uaid}/subscription")
Expand Down

0 comments on commit 8c4f23b

Please sign in to comment.