diff --git a/lib/types/tunnelbroker/notif-types.js b/lib/types/tunnelbroker/notif-types.js index 31c7c09b0..286dd9315 100644 --- a/lib/types/tunnelbroker/notif-types.js +++ b/lib/types/tunnelbroker/notif-types.js @@ -1,9 +1,17 @@ // @flow export type TunnelbrokerAPNsNotif = { +type: 'APNsNotif', +headers: string, +clientMessageID: string, +deviceID: string, +payload: string, }; + +export type TunnelbrokerFCMNotif = { + +type: 'FCMNotif', + +clientMessageID: string, + +deviceID: string, + +data: string, + +priority: 'NORMAL' | 'HIGH', +}; diff --git a/shared/tunnelbroker_messages/src/messages/mod.rs b/shared/tunnelbroker_messages/src/messages/mod.rs index f62304351..5ae3b693d 100644 --- a/shared/tunnelbroker_messages/src/messages/mod.rs +++ b/shared/tunnelbroker_messages/src/messages/mod.rs @@ -1,68 +1,69 @@ //! Messages sent between Tunnelbroker and a device. pub mod device_list_updated; pub mod keys; pub mod message_receive_confirmation; pub mod message_to_device; pub mod message_to_device_request; pub mod message_to_device_request_status; pub mod message_to_tunnelbroker; pub mod message_to_tunnelbroker_request; pub mod notif; pub mod session; pub use device_list_updated::*; pub use keys::*; pub use message_receive_confirmation::*; pub use message_to_device::*; pub use message_to_device_request::*; pub use message_to_device_request_status::*; pub use message_to_tunnelbroker::*; pub use message_to_tunnelbroker_request::*; pub use session::*; pub use websocket_messages::{ ConnectionInitializationResponse, ConnectionInitializationStatus, Heartbeat, }; use crate::notif::*; use serde::{Deserialize, Serialize}; // This file defines types and validation for messages exchanged // with the Tunnelbroker. The definitions in this file should remain in sync // with the structures defined in the corresponding // JavaScript file at `lib/types/tunnelbroker/messages.js`. // If you edit the definitions in one file, // please make sure to update the corresponding definitions in the other. #[derive(Serialize, Deserialize, Debug)] #[serde(untagged)] pub enum Messages { ConnectionInitializationMessage(ConnectionInitializationMessage), ConnectionInitializationResponse(ConnectionInitializationResponse), AnonymousInitializationMessage(AnonymousInitializationMessage), // MessageToDeviceRequestStatus must be placed before MessageToDeviceRequest. // This is due to serde's pattern matching behavior where it prioritizes // the first matching pattern it encounters. APNsNotif(APNsNotif), + FCMNotif(FCMNotif), MessageToDeviceRequestStatus(MessageToDeviceRequestStatus), MessageToDeviceRequest(MessageToDeviceRequest), MessageToDevice(MessageToDevice), MessageReceiveConfirmation(MessageReceiveConfirmation), MessageToTunnelbrokerRequest(MessageToTunnelbrokerRequest), Heartbeat(Heartbeat), IdentityDeviceListUpdated(IdentityDeviceListUpdated), } #[derive(Serialize, Deserialize, Debug)] #[serde(untagged)] pub enum PeerToPeerMessages { RefreshKeysRequest(RefreshKeyRequest), IdentityDeviceListUpdated(IdentityDeviceListUpdated), } #[derive(Serialize, Deserialize, Debug)] #[serde(untagged)] pub enum MessageToTunnelbroker { SetDeviceToken(SetDeviceToken), } diff --git a/shared/tunnelbroker_messages/src/messages/notif.rs b/shared/tunnelbroker_messages/src/messages/notif.rs index cb51df58c..400c7d7cc 100644 --- a/shared/tunnelbroker_messages/src/messages/notif.rs +++ b/shared/tunnelbroker_messages/src/messages/notif.rs @@ -1,14 +1,25 @@ -//! APNs notif built on client. - use serde::{Deserialize, Serialize}; +/// APNs notif built on client. #[derive(Serialize, Deserialize, PartialEq, Debug)] #[serde(tag = "type", rename_all = "camelCase")] pub struct APNsNotif { pub headers: String, #[serde(rename = "clientMessageID")] pub client_message_id: String, #[serde(rename = "deviceID")] pub device_id: String, pub payload: String, } + +/// FCM notif built on client. +#[derive(Serialize, Deserialize, PartialEq, Debug)] +#[serde(tag = "type", rename_all = "camelCase")] +pub struct FCMNotif { + #[serde(rename = "clientMessageID")] + pub client_message_id: String, + #[serde(rename = "deviceID")] + pub device_id: String, + pub data: String, + pub priority: String, +}