Skip to content

Commit

Permalink
feat: Support "gcm" as an alias to "fcm" (#211)
Browse files Browse the repository at this point in the history
Closes #204
  • Loading branch information
AzureMarker committed Aug 7, 2020
1 parent a28cb29 commit fd0d63d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion autoendpoint/src/extractors/router_data_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ impl FromRequest for RouterDataInput {
// Validate the token according to each router's token schema
let is_valid = match path_args.router_type {
RouterType::WebPush => true,
RouterType::FCM | RouterType::APNS => VALID_TOKEN.is_match(&data.token),
RouterType::FCM | RouterType::GCM | RouterType::APNS => {
VALID_TOKEN.is_match(&data.token)
}
RouterType::ADM => VALID_ADM_TOKEN.is_match(&data.token),
};

Expand Down
5 changes: 4 additions & 1 deletion autoendpoint/src/extractors/routers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::sync::Arc;
pub enum RouterType {
WebPush,
FCM,
GCM,
APNS,
ADM,
}
Expand All @@ -28,6 +29,7 @@ impl FromStr for RouterType {
match s {
"webpush" => Ok(RouterType::WebPush),
"fcm" => Ok(RouterType::FCM),
"gcm" => Ok(RouterType::GCM),
"apns" => Ok(RouterType::APNS),
"adm" => Ok(RouterType::ADM),
_ => Err(()),
Expand All @@ -40,6 +42,7 @@ impl Display for RouterType {
f.write_str(match self {
RouterType::WebPush => "webpush",
RouterType::FCM => "fcm",
RouterType::GCM => "gcm",
RouterType::APNS => "apns",
RouterType::ADM => "adm",
})
Expand Down Expand Up @@ -84,7 +87,7 @@ impl Routers {
pub fn get(&self, router_type: RouterType) -> &dyn Router {
match router_type {
RouterType::WebPush => &self.webpush,
RouterType::FCM => self.fcm.as_ref(),
RouterType::FCM | RouterType::GCM => self.fcm.as_ref(),
RouterType::APNS => self.apns.as_ref(),
RouterType::ADM => self.adm.as_ref(),
}
Expand Down

0 comments on commit fd0d63d

Please sign in to comment.