Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support "gcm" as an alias to "fcm" #211

Merged
merged 1 commit into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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