diff --git a/services/tunnelbroker/rust-notifications/src/lib.rs b/services/tunnelbroker/rust-notifications/src/lib.rs index af6a4faab..ca5179527 100644 --- a/services/tunnelbroker/rust-notifications/src/lib.rs +++ b/services/tunnelbroker/rust-notifications/src/lib.rs @@ -1,83 +1,82 @@ use crate::ffi::{apns_status, fcm_status}; use anyhow::Result; use env_logger; use lazy_static::lazy_static; use log::info; use tokio::runtime::Runtime; -pub mod apns; -pub mod fcm; +pub mod notifications; #[cxx::bridge] mod ffi { #[cxx_name = "apnsReturnStatus"] enum apns_status { Ok, Unregistered, BadDeviceToken, } #[cxx_name = "fcmReturnStatus"] enum fcm_status { Ok, InvalidRegistration, NotRegistered, } extern "Rust" { #[cxx_name = "sendNotifToAPNS"] fn send_notif_to_apns( certificate_path: &str, certificate_password: &str, device_token: &str, topic: &str, message: &str, sandbox: bool, ) -> Result; #[cxx_name = "sendNotifToFCM"] fn send_notif_to_fcm( fcm_api_key: &str, device_registration_id: &str, message_title: &str, message_body: &str, ) -> Result; } } lazy_static! { pub static ref RUNTIME: Runtime = { env_logger::init(); info!("Tokio runtime initialization"); Runtime::new().unwrap() }; } pub fn send_notif_to_apns( certificate_path: &str, certificate_password: &str, device_token: &str, topic: &str, message: &str, sandbox: bool, ) -> Result { - RUNTIME.block_on(apns::send_by_a2_client( + RUNTIME.block_on(notifications::apns::send_by_a2_client( certificate_path, certificate_password, device_token, topic, message, sandbox, )) } pub fn send_notif_to_fcm( fcm_api_key: &str, device_registration_id: &str, message_title: &str, message_body: &str, ) -> Result { - RUNTIME.block_on(fcm::send_by_fcm_client( + RUNTIME.block_on(notifications::fcm::send_by_fcm_client( fcm_api_key, device_registration_id, message_title, message_body, )) } diff --git a/services/tunnelbroker/rust-notifications/src/apns.rs b/services/tunnelbroker/rust-notifications/src/notifications/apns.rs similarity index 100% rename from services/tunnelbroker/rust-notifications/src/apns.rs rename to services/tunnelbroker/rust-notifications/src/notifications/apns.rs diff --git a/services/tunnelbroker/rust-notifications/src/fcm.rs b/services/tunnelbroker/rust-notifications/src/notifications/fcm.rs similarity index 100% rename from services/tunnelbroker/rust-notifications/src/fcm.rs rename to services/tunnelbroker/rust-notifications/src/notifications/fcm.rs diff --git a/services/tunnelbroker/rust-notifications/src/notifications/mod.rs b/services/tunnelbroker/rust-notifications/src/notifications/mod.rs new file mode 100644 index 000000000..a2c085121 --- /dev/null +++ b/services/tunnelbroker/rust-notifications/src/notifications/mod.rs @@ -0,0 +1,2 @@ +pub mod apns; +pub mod fcm;