diff --git a/keyserver/src/socket/session-utils.js b/keyserver/src/socket/session-utils.js --- a/keyserver/src/socket/session-utils.js +++ b/keyserver/src/socket/session-utils.js @@ -41,6 +41,7 @@ tPlatformDetails, } from 'lib/utils/validation-utils.js'; +import { createOlmSession } from '../creators/olm-session-creator.js'; import { saveOneTimeKeys } from '../creators/one-time-keys-creator.js'; import createReport from '../creators/report-creator.js'; import { SQL } from '../database/database.js'; @@ -131,6 +132,13 @@ ), signedIdentityKeysBlob: signedIdentityKeysBlobValidator, }), + tShape({ + type: t.irreducible( + 'serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE', + x => x === serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE, + ), + initialNotificationsEncryptedMessage: t.String, + }), ]); type StateCheckStatus = @@ -230,6 +238,24 @@ } catch (e) { continue; } + } else if ( + clientResponse.type === + serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE + ) { + invariant( + t.String.is(clientResponse.initialNotificationsEncryptedMessage), + 'initialNotificationsEncryptedMessage expected in client response', + ); + const { initialNotificationsEncryptedMessage } = clientResponse; + try { + await createOlmSession( + initialNotificationsEncryptedMessage, + 'notifications', + viewer.cookieID, + ); + } catch (e) { + continue; + } } }