diff --git a/lib/ops/keyserver-store-ops.js b/lib/ops/keyserver-store-ops.js --- a/lib/ops/keyserver-store-ops.js +++ b/lib/ops/keyserver-store-ops.js @@ -130,7 +130,32 @@ }, }; +function removeDeviceSpecificInfoFromDBKeyserverStoreOps( + keyservers: $ReadOnlyArray, +): $ReadOnlyArray { + const keyserverInfos = + keyserverStoreOpsHandlers.translateClientDBData(keyservers); + const operations: ReplaceKeyserverOperation[] = []; + for (const keyserverID in keyserverInfos) { + operations.push({ + type: 'replace_keyserver', + payload: { + id: keyserverID, + keyserverInfo: { + ...keyserverInfos[keyserverID], + cookie: null, + lastCommunicatedPlatformDetails: null, + deviceToken: null, + updatesCurrentAsOf: 0, + }, + }, + }); + } + return keyserverStoreOpsHandlers.convertOpsToClientDBOps(operations); +} + export { keyserverStoreOpsHandlers, convertKeyserverInfoToClientDBKeyserverInfo, + removeDeviceSpecificInfoFromDBKeyserverStoreOps, }; diff --git a/native/backup/use-client-backup.js b/native/backup/use-client-backup.js --- a/native/backup/use-client-backup.js +++ b/native/backup/use-client-backup.js @@ -2,6 +2,7 @@ import * as React from 'react'; +import { removeDeviceSpecificInfoFromDBKeyserverStoreOps } from 'lib/ops/keyserver-store-ops.js'; import { isLoggedIn } from 'lib/selectors/user-selectors.js'; import { fetchNativeKeychainCredentials } from '../account/native-credentials.js'; @@ -67,6 +68,11 @@ const backupSecret = await getBackupSecret(); await commCoreModule.restoreBackup(backupSecret); + const { keyservers } = await commCoreModule.getClientDBStore(); + const operations = + removeDeviceSpecificInfoFromDBKeyserverStoreOps(keyservers); + await commCoreModule.processKeyserverStoreOperations(operations); + console.info('Backup restored.'); }, [currentUserID, loggedIn, setMockCommServicesAuthMetadata]); diff --git a/web/database/worker/backup.js b/web/database/worker/backup.js --- a/web/database/worker/backup.js +++ b/web/database/worker/backup.js @@ -4,8 +4,10 @@ import backupService from 'lib/facts/backup-service.js'; import { decryptCommon } from 'lib/media/aes-crypto-utils-common.js'; +import { removeDeviceSpecificInfoFromDBKeyserverStoreOps } from 'lib/ops/keyserver-store-ops.js'; import type { AuthMetadata } from 'lib/shared/identity-client-context.js'; +import { processKeyserverStoreOperations } from './process-operations.js'; import { completeRootKey } from '../../redux/persist-constants.js'; import type { EmscriptenModule } from '../types/module.js'; import type { SQLiteQueryExecutor } from '../types/sqlite-query-executor.js'; @@ -53,6 +55,11 @@ sqliteQueryExecutor.setPersistStorageItem(completeRootKey, reduxPersistData); + const keyservers = sqliteQueryExecutor.getAllKeyservers(); + const operations = + removeDeviceSpecificInfoFromDBKeyserverStoreOps(keyservers); + processKeyserverStoreOperations(sqliteQueryExecutor, operations, dbModule); + await client.downloadLogs(userIdentity, backupID, async log => { const content = await decryptCommon(crypto, decryptionKey, log); sqliteQueryExecutor.restoreFromBackupLog(content); diff --git a/web/database/worker/process-operations.js b/web/database/worker/process-operations.js --- a/web/database/worker/process-operations.js +++ b/web/database/worker/process-operations.js @@ -220,4 +220,8 @@ }; } -export { processDBStoreOperations, getClientStoreFromQueryExecutor }; +export { + processDBStoreOperations, + getClientStoreFromQueryExecutor, + processKeyserverStoreOperations, +};