Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/socket/socket.js
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | import { | ||||
verifyCalendarQueryThreadIDs, | verifyCalendarQueryThreadIDs, | ||||
} from '../responders/entry-responders.js'; | } from '../responders/entry-responders.js'; | ||||
import { handleAsyncPromise } from '../responders/handlers.js'; | import { handleAsyncPromise } from '../responders/handlers.js'; | ||||
import { | import { | ||||
fetchViewerForSocket, | fetchViewerForSocket, | ||||
extendCookieLifespan, | extendCookieLifespan, | ||||
createNewAnonymousCookie, | createNewAnonymousCookie, | ||||
isCookieMissingSignedIdentityKeysBlob, | isCookieMissingSignedIdentityKeysBlob, | ||||
isCookieMissingOlmNotificationsSession, | |||||
} from '../session/cookies.js'; | } from '../session/cookies.js'; | ||||
import { Viewer } from '../session/viewer.js'; | import { Viewer } from '../session/viewer.js'; | ||||
import { commitSessionUpdate } from '../updaters/session-updaters.js'; | import { commitSessionUpdate } from '../updaters/session-updaters.js'; | ||||
import { assertSecureRequest } from '../utils/security-utils.js'; | import { assertSecureRequest } from '../utils/security-utils.js'; | ||||
import { | import { | ||||
checkInputValidator, | checkInputValidator, | ||||
checkClientSupported, | checkClientSupported, | ||||
policiesValidator, | policiesValidator, | ||||
▲ Show 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | const messagesResult = { | ||||
fetchMessagesResult.rawMessageInfos, | fetchMessagesResult.rawMessageInfos, | ||||
oldMessagesCurrentAsOf, | oldMessagesCurrentAsOf, | ||||
), | ), | ||||
}; | }; | ||||
const isCookieMissingSignedIdentityKeysBlobPromise = | const isCookieMissingSignedIdentityKeysBlobPromise = | ||||
isCookieMissingSignedIdentityKeysBlob(viewer.cookieID); | isCookieMissingSignedIdentityKeysBlob(viewer.cookieID); | ||||
const isCookieMissingOlmNotificationsSessionPromise = | |||||
isCookieMissingOlmNotificationsSession(viewer); | |||||
if (!sessionInitializationResult.sessionContinued) { | if (!sessionInitializationResult.sessionContinued) { | ||||
const [threadsResult, entriesResult, currentUserInfo, knownUserInfos] = | const [threadsResult, entriesResult, currentUserInfo, knownUserInfos] = | ||||
await Promise.all([ | await Promise.all([ | ||||
fetchThreadInfos(viewer), | fetchThreadInfos(viewer), | ||||
fetchEntryInfos(viewer, [calendarQuery]), | fetchEntryInfos(viewer, [calendarQuery]), | ||||
fetchCurrentUserInfo(viewer), | fetchCurrentUserInfo(viewer), | ||||
fetchKnownUserInfos(viewer), | fetchKnownUserInfos(viewer), | ||||
]); | ]); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if (!sessionInitializationResult.sessionContinued) { | ||||
updatesResult, | updatesResult, | ||||
deltaEntryInfos: deltaEntryInfoResult.rawEntryInfos, | deltaEntryInfos: deltaEntryInfoResult.rawEntryInfos, | ||||
deletedEntryIDs: deltaEntryInfoResult.deletedEntryIDs, | deletedEntryIDs: deltaEntryInfoResult.deletedEntryIDs, | ||||
userInfos: values(userInfos), | userInfos: values(userInfos), | ||||
}, | }, | ||||
}); | }); | ||||
} | } | ||||
const signedIdentityKeysBlobMissing = | const [signedIdentityKeysBlobMissing, olmNotificationsSessionMissing] = | ||||
await isCookieMissingSignedIdentityKeysBlobPromise; | await Promise.all([ | ||||
isCookieMissingSignedIdentityKeysBlobPromise, | |||||
isCookieMissingOlmNotificationsSessionPromise, | |||||
]); | |||||
if (signedIdentityKeysBlobMissing) { | if (signedIdentityKeysBlobMissing) { | ||||
serverRequests.push({ | serverRequests.push({ | ||||
type: serverRequestTypes.SIGNED_IDENTITY_KEYS_BLOB, | type: serverRequestTypes.SIGNED_IDENTITY_KEYS_BLOB, | ||||
}); | }); | ||||
} | } | ||||
if (olmNotificationsSessionMissing) { | |||||
serverRequests.push({ | |||||
type: serverRequestTypes.INITIAL_NOTIFICATIONS_ENCRYPTED_MESSAGE, | |||||
}); | |||||
} | |||||
if (serverRequests.length > 0 || clientResponses.length > 0) { | if (serverRequests.length > 0 || clientResponses.length > 0) { | ||||
// We send this message first since the STATE_SYNC triggers the client's | // We send this message first since the STATE_SYNC triggers the client's | ||||
// connection status to shift to "connected", and we want to make sure the | // connection status to shift to "connected", and we want to make sure the | ||||
// client responses are cleared from Redux before that happens | // client responses are cleared from Redux before that happens | ||||
responses.unshift({ | responses.unshift({ | ||||
type: serverSocketMessageTypes.REQUESTS, | type: serverSocketMessageTypes.REQUESTS, | ||||
responseTo: message.id, | responseTo: message.id, | ||||
payload: { serverRequests }, | payload: { serverRequests }, | ||||
▲ Show 20 Lines • Show All 270 Lines • Show Last 20 Lines |