Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3571339
D12753.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12753.id.diff
View Options
diff --git a/services/tunnelbroker/src/main.rs b/services/tunnelbroker/src/main.rs
--- a/services/tunnelbroker/src/main.rs
+++ b/services/tunnelbroker/src/main.rs
@@ -9,6 +9,7 @@
pub mod websockets;
use crate::notifs::apns::APNsClient;
+use crate::notifs::fcm::FCMClient;
use crate::notifs::NotifClient;
use anyhow::{anyhow, Result};
use config::CONFIG;
@@ -52,8 +53,24 @@
};
let fcm_config = CONFIG.fcm_config.clone();
+ let fcm = match fcm_config {
+ Some(config) => match FCMClient::new(&config) {
+ Ok(fcm_client) => {
+ info!("FCM client created successfully");
+ Some(fcm_client)
+ }
+ Err(err) => {
+ error!("Error creating FCM client: {}", err);
+ None
+ }
+ },
+ None => {
+ error!("FCM config is missing");
+ None
+ }
+ };
- let notif_client = NotifClient { apns, fcm: None };
+ let notif_client = NotifClient { apns, fcm };
let grpc_server = grpc::run_server(db_client.clone(), &amqp_connection);
let websocket_server = websockets::run_server(
diff --git a/services/tunnelbroker/src/notifs/fcm/error.rs b/services/tunnelbroker/src/notifs/fcm/error.rs
new file mode 100644
--- /dev/null
+++ b/services/tunnelbroker/src/notifs/fcm/error.rs
@@ -0,0 +1,15 @@
+use derive_more::{Display, Error, From};
+
+#[derive(Debug, From, Display, Error)]
+pub enum Error {
+ JWTError,
+ ReqwestError(reqwest::Error),
+ InvalidHeaderValue(reqwest::header::InvalidHeaderValue),
+ SerdeJson(serde_json::Error),
+}
+
+impl From<jsonwebtoken::errors::Error> for Error {
+ fn from(_: jsonwebtoken::errors::Error) -> Self {
+ Self::JWTError
+ }
+}
diff --git a/services/tunnelbroker/src/notifs/fcm/mod.rs b/services/tunnelbroker/src/notifs/fcm/mod.rs
--- a/services/tunnelbroker/src/notifs/fcm/mod.rs
+++ b/services/tunnelbroker/src/notifs/fcm/mod.rs
@@ -1,6 +1,20 @@
+use crate::notifs::fcm::config::FCMConfig;
+
pub mod config;
+mod error;
#[derive(Clone)]
pub struct FCMClient {
- http2_client: reqwest::Client,
+ http_client: reqwest::Client,
+ config: FCMConfig,
+}
+
+impl FCMClient {
+ pub fn new(config: &FCMConfig) -> Result<Self, error::Error> {
+ let http_client = reqwest::Client::builder().build()?;
+ Ok(FCMClient {
+ http_client,
+ config: config.clone(),
+ })
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 29, 9:04 AM (4 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2728830
Default Alt Text
D12753.id.diff (2 KB)
Attached To
Mode
D12753: [Tunnelbroker] implement creating FCM client
Attached
Detach File
Event Timeline
Log In to Comment