Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3370808
D12225.id40755.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12225.id40755.diff
View Options
diff --git a/lib/handlers/peer-to-peer-message-handler.js b/lib/handlers/peer-to-peer-message-handler.js
--- a/lib/handlers/peer-to-peer-message-handler.js
+++ b/lib/handlers/peer-to-peer-message-handler.js
@@ -2,7 +2,10 @@
import _isEqual from 'lodash/fp/isEqual.js';
-import { verifyAndGetDeviceList } from '../shared/device-list-utils.js';
+import {
+ verifyAndGetDeviceList,
+ removeDeviceFromDeviceList,
+} from '../shared/device-list-utils.js';
import type {
IdentityServiceClient,
DeviceOlmInboundKeys,
@@ -11,6 +14,7 @@
peerToPeerMessageTypes,
type PeerToPeerMessage,
} from '../types/tunnelbroker/peer-to-peer-message-types.js';
+import { secondaryDeviceLogoutP2PMessageValidator } from '../types/tunnelbroker/user-actions-peer-to-peer-message-types.js';
import { getConfig } from '../utils/config.js';
import { getContentSigningKey } from '../utils/crypto-utils.js';
import { getMessageForException } from '../utils/errors.js';
@@ -106,6 +110,24 @@
'Decrypted message from device ' +
`${message.senderInfo.deviceID}: ${decrypted}`,
);
+
+ try {
+ const parsedMessageToDevice = JSON.parse(decrypted);
+ if (
+ !secondaryDeviceLogoutP2PMessageValidator.is(parsedMessageToDevice)
+ ) {
+ return;
+ }
+ const { userID, deviceID: deviceIDToLogOut } = message.senderInfo;
+ await removeDeviceFromDeviceList(
+ identityClient,
+ userID,
+ deviceIDToLogOut,
+ );
+ // TODO: broadcast device list update here
+ } catch (e) {
+ console.log(e);
+ }
} catch (e) {
if (e.message?.includes(olmSessionErrors.messageAlreadyDecrypted)) {
console.log(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 4:05 AM (13 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2587700
Default Alt Text
D12225.id40755.diff (1 KB)
Attached To
Mode
D12225: [lib][p2p] Update device list upon receiving logout message
Attached
Detach File
Event Timeline
Log In to Comment