diff --git a/keyserver/src/utils/identity-utils.js b/keyserver/src/utils/identity-utils.js --- a/keyserver/src/utils/identity-utils.js +++ b/keyserver/src/utils/identity-utils.js @@ -70,9 +70,29 @@ ); } +async function uploadOneTimeKeys( + identityInfo: IdentityInfo, + contentOneTimeKeys: $ReadOnlyArray, + notifOneTimeKeys: $ReadOnlyArray, +): Promise { + const [rustAPI, deviceID] = await Promise.all([ + getRustAPI(), + getContentSigningKey(), + ]); + + await rustAPI.uploadOneTimeKeys( + identityInfo.userId, + deviceID, + identityInfo.accessToken, + contentOneTimeKeys, + notifOneTimeKeys, + ); +} + export { findUserIdentities, privilegedDeleteUsers, privilegedResetUserPassword, syncPlatformDetails, + uploadOneTimeKeys, }; diff --git a/keyserver/src/utils/olm-utils.js b/keyserver/src/utils/olm-utils.js --- a/keyserver/src/utils/olm-utils.js +++ b/keyserver/src/utils/olm-utils.js @@ -21,6 +21,7 @@ retrieveAccountKeysSet, } from 'lib/utils/olm-utils.js'; +import { uploadOneTimeKeys } from './identity-utils.js'; import { fetchCallUpdateOlmAccount, fetchOlmAccount, @@ -207,12 +208,7 @@ } async function uploadNewOneTimeKeys(numberOfKeys: number) { - const [rustAPI, identityInfo, deviceID] = await Promise.all([ - getRustAPI(), - verifyUserLoggedIn(), - getContentSigningKey(), - ]); - + const identityInfo = await verifyUserLoggedIn(); if (!identityInfo) { throw new ServerError('missing_identity_info'); } @@ -246,13 +242,7 @@ 'notif one-time keys not set after fetchCallUpdateOlmAccount', ); - await rustAPI.uploadOneTimeKeys( - identityInfo.userId, - deviceID, - identityInfo.accessToken, - contentOneTimeKeys, - notifOneTimeKeys, - ); + await uploadOneTimeKeys(identityInfo, contentOneTimeKeys, notifOneTimeKeys); } async function getContentSigningKey(): Promise {