diff --git a/lib/handlers/tunnelbroker-device-token-handler.react.js b/lib/handlers/tunnelbroker-device-token-handler.react.js --- a/lib/handlers/tunnelbroker-device-token-handler.react.js +++ b/lib/handlers/tunnelbroker-device-token-handler.react.js @@ -6,8 +6,9 @@ import { useTunnelbroker } from '../tunnelbroker/tunnelbroker-context.js'; import { messageToTunnelbrokerTypes, - type SetDeviceToken, + type SetDeviceTokenWithPlatform, } from '../types/tunnelbroker/message-to-tunnelbroker-types.js'; +import { getConfig } from '../utils/config.js'; import { useDispatchActionPromise } from '../utils/redux-promise-utils.js'; import { useSelector } from '../utils/redux-utils.js'; @@ -20,6 +21,8 @@ const { socketState, sendMessageToTunnelbroker } = useTunnelbroker(); React.useEffect(() => { + const { platform } = getConfig().platformDetails; + if ( !socketState.isAuthorized || !tunnelbrokerDeviceToken.localToken || @@ -29,9 +32,10 @@ return; } - const message: SetDeviceToken = { - type: messageToTunnelbrokerTypes.SET_DEVICE_TOKEN, + const message: SetDeviceTokenWithPlatform = { + type: messageToTunnelbrokerTypes.SET_DEVICE_TOKEN_WITH_PLATFORM, deviceToken: tunnelbrokerDeviceToken.localToken, + platform, }; const deviceToken = tunnelbrokerDeviceToken.localToken; const promise: Promise<{ deviceToken: string }> = (async () => { 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 @@ -293,6 +293,18 @@ ) .await?; } + MessageToTunnelbroker::SetDeviceTokenWithPlatform( + token_with_platform, + ) => { + self + .db_client + .set_device_token( + &self.device_info.device_id, + &token_with_platform.device_token, + Some(token_with_platform.platform.clone()), + ) + .await?; + } } Ok(()) diff --git a/shared/tunnelbroker_messages/src/messages/mod.rs b/shared/tunnelbroker_messages/src/messages/mod.rs --- a/shared/tunnelbroker_messages/src/messages/mod.rs +++ b/shared/tunnelbroker_messages/src/messages/mod.rs @@ -78,5 +78,6 @@ #[derive(Serialize, Deserialize, Debug)] #[serde(untagged)] pub enum MessageToTunnelbroker { + SetDeviceTokenWithPlatform(SetDeviceTokenWithPlatform), SetDeviceToken(SetDeviceToken), }