diff --git a/keyserver/src/updaters/olm-account-updater.js b/keyserver/src/updaters/olm-account-updater.js --- a/keyserver/src/updaters/olm-account-updater.js +++ b/keyserver/src/updaters/olm-account-updater.js @@ -7,7 +7,6 @@ import { SQL, dbQuery } from '../database/database.js'; import { unpickleAccountAndUseCallback } from '../utils/olm-objects.js'; -import { unpickleOlmAccount } from '../utils/olm-utils.js'; const maxOlmAccountUpdateRetriesCount = 5; const olmAccountUpdateRetryDelay = 200; @@ -86,32 +85,4 @@ throw new ServerError('max_olm_account_update_retry_exceeded'); } -async function fetchOlmAccount( - olmAccountType: 'content' | 'notifications', -): Promise<{ - account: OlmAccount, - picklingKey: string, -}> { - const isContent = olmAccountType === 'content'; - const [olmAccountResult] = await dbQuery( - SQL` - SELECT pickling_key, pickled_olm_account - FROM olm_accounts - WHERE is_content = ${isContent} - `, - ); - if (olmAccountResult.length === 0) { - throw new ServerError('missing_olm_account'); - } - const picklingKey = olmAccountResult[0].pickling_key; - const pickledAccount = olmAccountResult[0].pickled_olm_account; - - const account = await unpickleOlmAccount({ - picklingKey, - pickledAccount, - }); - - return { account, picklingKey }; -} - -export { fetchCallUpdateOlmAccount, fetchOlmAccount }; +export { fetchCallUpdateOlmAccount }; diff --git a/keyserver/src/updaters/olm-session-updater.js b/keyserver/src/updaters/olm-session-updater.js --- a/keyserver/src/updaters/olm-session-updater.js +++ b/keyserver/src/updaters/olm-session-updater.js @@ -5,8 +5,8 @@ import { ServerError } from 'lib/utils/errors.js'; import sleep from 'lib/utils/sleep.js'; -import { fetchOlmAccount } from './olm-account-updater.js'; import { SQL, dbQuery } from '../database/database.js'; +import { fetchPickledOlmAccount } from '../fetchers/olm-account-fetchers.js'; import { unpickleOlmSession } from '../utils/olm-utils.js'; const maxOlmSessionUpdateAttemptTime = 30000; @@ -25,7 +25,7 @@ dbPersistCondition?: ({ +[string]: EncryptResult }) => boolean, ): Promise { const isContent = olmSessionType === 'content'; - const { picklingKey } = await fetchOlmAccount(olmSessionType); + const { picklingKey } = await fetchPickledOlmAccount(olmSessionType); const olmUpdateAttemptStartTime = Date.now(); while ( 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 @@ -40,19 +40,6 @@ }; } -async function unpickleOlmAccount( - pickledOlmAccount: PickledOlmAccount, -): Promise { - await olm.init(); - const account = new olm.Account(); - - account.unpickle( - pickledOlmAccount.picklingKey, - pickledOlmAccount.pickledAccount, - ); - return account; -} - async function createPickledOlmSession( account: OlmAccount, accountPicklingKey: string, @@ -306,7 +293,6 @@ export { createPickledOlmAccount, createPickledOlmSession, - unpickleOlmAccount, unpickleOlmSession, uploadNewOneTimeKeys, getContentSigningKey,