diff --git a/lib/types/tunnelbroker/notif-types.js b/lib/types/tunnelbroker/notif-types.js
--- a/lib/types/tunnelbroker/notif-types.js
+++ b/lib/types/tunnelbroker/notif-types.js
@@ -23,7 +23,15 @@
+payload: string,
};
+export type TunnelbrokerWNSNotif = {
+ +type: 'WNSNotif',
+ +clientMessageID: string,
+ +deviceID: string,
+ +payload: string,
+};
+
export type TunnelbrokerNotif =
| TunnelbrokerAPNsNotif
| TunnelbrokerFCMNotif
- | TunnelbrokerWebPushNotif;
+ | TunnelbrokerWebPushNotif
+ | TunnelbrokerWNSNotif;
diff --git a/services/tunnelbroker/src/notifs/mod.rs b/services/tunnelbroker/src/notifs/mod.rs
--- a/services/tunnelbroker/src/notifs/mod.rs
+++ b/services/tunnelbroker/src/notifs/mod.rs
@@ -14,7 +14,7 @@
APNs,
FCM,
WebPush,
- WNs,
+ WNS,
}
impl NotifClientType {
@@ -25,7 +25,7 @@
}
NotifClientType::FCM => platform == Platform::Android,
NotifClientType::WebPush => platform == Platform::Web,
- NotifClientType::WNs => platform == Platform::Windows,
+ NotifClientType::WNS => platform == Platform::Windows,
}
}
}
diff --git a/services/tunnelbroker/src/notifs/wns/error.rs b/services/tunnelbroker/src/notifs/wns/error.rs
--- a/services/tunnelbroker/src/notifs/wns/error.rs
+++ b/services/tunnelbroker/src/notifs/wns/error.rs
@@ -1,5 +1,7 @@
use derive_more::{Display, Error, From};
+use super::response::WNSErrorResponse;
+
#[derive(Debug, From, Display, Error)]
pub enum Error {
Reqwest(reqwest::Error),
@@ -12,4 +14,6 @@
ReadLock,
#[display(fmt = "Failed to acquire write lock")]
WriteLock,
+ #[display(fmt = "WNS Notification Error: {}", _0)]
+ WNSNotification(WNSErrorResponse),
}
diff --git a/services/tunnelbroker/src/notifs/wns/mod.rs b/services/tunnelbroker/src/notifs/wns/mod.rs
--- a/services/tunnelbroker/src/notifs/wns/mod.rs
+++ b/services/tunnelbroker/src/notifs/wns/mod.rs
@@ -1,4 +1,6 @@
use crate::notifs::wns::config::WNSConfig;
+use reqwest::StatusCode;
+use response::WNSErrorResponse;
use std::{
sync::{Arc, RwLock},
time::{Duration, SystemTime},
@@ -6,6 +8,7 @@
pub mod config;
mod error;
+mod response;
#[derive(Debug, Clone)]
pub struct WNSAccessToken {
@@ -13,6 +16,12 @@
expires: SystemTime,
}
+#[derive(Debug, Clone)]
+pub struct WNSNotif {
+ pub device_token: String,
+ pub payload: String,
+}
+
#[derive(Clone)]
pub struct WNSClient {
http_client: reqwest::Client,
@@ -30,9 +39,48 @@
})
}
- pub async fn get_wns_token(
- &mut self,
- ) -> Result