diff --git a/services/tunnelbroker/rust-notifications/src/fcm.rs b/services/tunnelbroker/rust-notifications/src/fcm.rs --- a/services/tunnelbroker/rust-notifications/src/fcm.rs +++ b/services/tunnelbroker/rust-notifications/src/fcm.rs @@ -6,7 +6,7 @@ device_registration_id: &str, message_title: &str, message_body: &str, -) -> Result { +) -> Result<()> { let client = Client::new(); let mut notification_builder = NotificationBuilder::new(); notification_builder.title(message_title); @@ -17,8 +17,19 @@ MessageBuilder::new(fcm_api_key, device_registration_id); message_builder.notification(notification); let result = client.send(message_builder.finalize()).await?; - match result.message_id { - Some(message_id) => Ok(message_id), - None => Err(anyhow!("FCM client returned an empty message id")), + match result.results { + Some(results) => { + if results.len() == 0 { + return Err(anyhow!("Client returned zero size results")); + } + for result in results { + match result.error { + Some(error) => return Err(anyhow!("Result error: {:?}", error)), + None => (), + } + } + } + None => return Err(anyhow!("Client has no results set")), } + Ok(()) } diff --git a/services/tunnelbroker/rust-notifications/src/lib.rs b/services/tunnelbroker/rust-notifications/src/lib.rs --- a/services/tunnelbroker/rust-notifications/src/lib.rs +++ b/services/tunnelbroker/rust-notifications/src/lib.rs @@ -22,7 +22,7 @@ device_registration_id: &str, message_title: &str, message_body: &str, - ) -> Result; + ) -> Result<()>; } } @@ -52,7 +52,7 @@ device_registration_id: &str, message_title: &str, message_body: &str, -) -> Result { +) -> Result<()> { RUNTIME.block_on(fcm::send_by_fcm_client( fcm_api_key, device_registration_id,