Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2753619
D12896.id42834.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
D12896.id42834.diff
View Options
diff --git a/services/tunnelbroker/src/websockets/session.rs b/services/tunnelbroker/src/websockets/session.rs
--- a/services/tunnelbroker/src/websockets/session.rs
+++ b/services/tunnelbroker/src/websockets/session.rs
@@ -33,6 +33,7 @@
use crate::notifs::fcm::firebase_message::{
AndroidConfig, AndroidMessagePriority, FCMMessage,
};
+use crate::notifs::web_push::WebPushNotif;
use crate::notifs::NotifClient;
pub struct DeviceInfo {
@@ -68,6 +69,7 @@
DatabaseError(comm_lib::database::Error),
MissingAPNsClient,
MissingFCMClient,
+ MissingWebPushClient,
MissingDeviceToken,
}
@@ -456,6 +458,44 @@
Err(SessionError::MissingFCMClient),
))
}
+ DeviceToTunnelbrokerMessage::WebPushNotif(notif) => {
+ // unauthenticated clients cannot send notifs
+ if !self.device_info.is_authenticated {
+ debug!(
+ "Unauthenticated device {} tried to send web push notif. Aborting.",
+ self.device_info.device_id
+ );
+ return Some(MessageSentStatus::Unauthenticated);
+ }
+ debug!("Received WebPush notif for {}", notif.device_id);
+
+ let Some(web_push_client) = self.notif_client.web_push.clone() else {
+ return Some(self.get_message_to_device_status(
+ ¬if.client_message_id,
+ Err(SessionError::MissingWebPushClient),
+ ));
+ };
+
+ let device_token = match self.get_device_token(notif.device_id).await {
+ Ok(token) => token,
+ Err(e) => {
+ return Some(
+ self
+ .get_message_to_device_status(¬if.client_message_id, Err(e)),
+ )
+ }
+ };
+
+ let web_push_notif = WebPushNotif {
+ device_token,
+ payload: notif.payload,
+ };
+
+ let result = web_push_client.send(web_push_notif).await;
+ Some(
+ self.get_message_to_device_status(¬if.client_message_id, result),
+ )
+ }
_ => {
error!("Client sent invalid message type");
Some(MessageSentStatus::InvalidRequest)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Sep 19, 5:58 PM (8 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2141338
Default Alt Text
D12896.id42834.diff (2 KB)
Attached To
Mode
D12896: [tunnelbroker] Implement sending WebPush notifs by clients
Attached
Detach File
Event Timeline
Log In to Comment