Skip to content

Commit

Permalink
feat: Server support for Android push notifications (#236)
Browse files Browse the repository at this point in the history
* feat: Server support for Android push notifications

* Address review comments
  • Loading branch information
raphaelrobert authored Dec 9, 2024
1 parent 954da7e commit f5b685a
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 124 deletions.
60 changes: 31 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions backend/src/qs/client_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ impl QsClientRecord {
"Push notification failed because the JWT token could not be created: {}",
e
),
PushNotificationError::OAuthError(e) => tracing::error!(
"Push notification failed because of an OAuth error: {}",
e
),
PushNotificationError::InvalidConfiguration(e) => tracing::error!(
"Push notification failed because of an invalid configuration: {}",
e
),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions backend/src/qs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ pub enum PushNotificationError {
UnsupportedType,
/// The JWT token for APNS could not be created.
JwtCreationError(String),
/// OAuth error.
OAuthError(String),
/// Configuration error.
InvalidConfiguration(String),
}

#[async_trait]
Expand Down
9 changes: 9 additions & 0 deletions backend/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub struct Settings {
// If this isn't present, the provider will not send push notifications to
// apple devices.
pub apns: Option<ApnsSettings>,
// If this isn't present, the provider will not send push notifications to
// android devices.
pub fcm: Option<FcmSettings>,
}

/// Configuration for the application.
Expand All @@ -33,6 +36,12 @@ pub struct DatabaseSettings {
pub cacertpath: Option<String>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct FcmSettings {
// The path to the service account key file.
pub path: String,
}

#[derive(Debug, Deserialize, Clone)]
pub struct ApnsSettings {
pub keyid: String,
Expand Down
2 changes: 2 additions & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ phnxbackend = { path = "../backend" }
phnxtypes = { path = "../types" }
actix-web = "^4.0"
serde = "1"
serde_json = "1.0"
config = "0.14"
async-trait = "0.1.74"
actix-web-actors = "4.2.0"
Expand All @@ -39,6 +40,7 @@ tracing-bunyan-formatter = "0.3"
tracing-actix-web = "0.7"
jsonwebtoken = "9"
opaque-ke = { version = "3.0.0-pre.5", features = ["argon2"] }
zeroize = "1.8.1"

# Workspace dependencies
tls_codec = { workspace = true }
Expand Down
Loading

0 comments on commit f5b685a

Please sign in to comment.