Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359575
D12767.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
D12767.diff
View Options
diff --git a/services/tunnelbroker/src/notifs/fcm/firebase_message.rs b/services/tunnelbroker/src/notifs/fcm/firebase_message.rs
new file mode 100644
--- /dev/null
+++ b/services/tunnelbroker/src/notifs/fcm/firebase_message.rs
@@ -0,0 +1,48 @@
+use serde::{Deserialize, Serialize};
+use serde_json::Value;
+
+#[derive(Debug, Serialize)]
+pub struct FCMMessageWrapper {
+ pub message: FCMMessage,
+}
+
+/// Message to send by Firebase Cloud Messaging Service.
+#[derive(Debug, Serialize)]
+pub struct FCMMessage {
+ /// Arbitrary key/value payload, which must be UTF-8 encoded.
+ pub data: Value,
+ /// Target to send a notification/message to.
+ pub token: String,
+ /// Android specific options for messages sent through FCM connection server.
+ pub android: AndroidConfig,
+}
+
+#[derive(Debug, Serialize)]
+pub struct AndroidConfig {
+ /// Message priority. Can take "normal" and "high" values.
+ pub priority: AndroidMessagePriority,
+}
+
+#[derive(Serialize, Deserialize, Debug)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum AndroidMessagePriority {
+ /// Default priority for data messages. Normal priority messages won't
+ /// open network connections on a sleeping device, and their delivery
+ /// may be delayed to conserve the battery.
+ Normal,
+ /// Default priority for notification messages. FCM attempts to deliver
+ /// high priority messages immediately, allowing the FCM service to wake
+ /// a sleeping device when possible and open a network connection to
+ /// your app server.
+ High,
+}
+
+impl AndroidMessagePriority {
+ pub fn from_str(value: &str) -> Option<Self> {
+ match value {
+ "NORMAL" => Some(AndroidMessagePriority::Normal),
+ "HIGH" => Some(AndroidMessagePriority::High),
+ _ => None,
+ }
+ }
+}
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
@@ -4,6 +4,7 @@
pub mod config;
mod error;
+mod firebase_message;
mod token;
#[derive(Clone)]
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 9:43 AM (20 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2579248
Default Alt Text
D12767.diff (2 KB)
Attached To
Mode
D12767: [Tunnelbroker] implement messages types to FCM service
Attached
Detach File
Event Timeline
Log In to Comment