Delete PNI storageID on merge

This commit is contained in:
Fedor Indutny 2023-05-25 00:05:04 +02:00 committed by GitHub
parent 1a737ee605
commit 3c7502213b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 5 deletions

View file

@ -189,7 +189,7 @@
"@electron/fuses": "1.5.0",
"@formatjs/intl": "2.6.7",
"@mixer/parallel-prettier": "2.0.3",
"@signalapp/mock-server": "2.20.0",
"@signalapp/mock-server": "2.21.1",
"@storybook/addon-a11y": "6.5.6",
"@storybook/addon-actions": "6.5.6",
"@storybook/addon-controls": "6.5.6",

View file

@ -30,6 +30,7 @@ import { MINUTE, SECOND } from './util/durations';
import { getUuidsForE164s } from './util/getUuidsForE164s';
import { SIGNAL_ACI, SIGNAL_AVATAR_PATH } from './types/SignalConversation';
import { getTitleNoDefault } from './util/getTitle';
import * as StorageService from './services/storage';
type ConvoMatchType =
| {
@ -1088,6 +1089,20 @@ export class ConversationController {
log.warn(`${logId}: Delete the obsolete conversation from the database`);
await removeConversation(obsoleteId);
const obsoleteStorageID = obsolete.get('storageID');
if (obsoleteStorageID) {
log.warn(
`${logId}: Obsolete conversation was in storage service, scheduling removal`
);
const obsoleteStorageVersion = obsolete.get('storageVersion');
StorageService.addPendingDelete({
storageID: obsoleteStorageID,
storageVersion: obsoleteStorageVersion,
});
}
log.warn(`${logId}: Update cached messages in MessageController`);
window.MessageController.update((message: MessageModel) => {
if (message.get('conversationId') === obsoleteId) {

View file

@ -1999,3 +1999,16 @@ export const runStorageServiceSyncJob = debounce(() => {
}, `sync v${window.storage.get('manifestVersion')}`)
);
}, 500);
export const addPendingDelete = (item: ExtendedStorageID): void => {
void storageJobQueue(async () => {
const storedPendingDeletes = window.storage.get(
'storage-service-pending-deletes',
[]
);
await window.storage.put('storage-service-pending-deletes', [
...storedPendingDeletes,
item,
]);
}, `addPendingDelete(${redactExtendedStorageID(item)})`);
};

View file

@ -358,6 +358,8 @@ describe('pnp/PNI Signature', function needsName() {
// No notifications
const notifications = window.locator('.SystemMessage');
assert.strictEqual(await notifications.count(), 0, 'notifications');
assert.isEmpty(await phone.getOrphanedStorageKeys());
}
});
});

View file

@ -2280,10 +2280,10 @@
node-gyp-build "^4.2.3"
uuid "^8.3.0"
"@signalapp/mock-server@2.20.0":
version "2.20.0"
resolved "https://registry.yarnpkg.com/@signalapp/mock-server/-/mock-server-2.20.0.tgz#073e0ef1a4c077d638440003a66be05feafb8bd3"
integrity sha512-RdwGZOlZLdsNfM3uzpaU/RkpCAhswF74NC96F7Sw1yOE05Ig/4Cpdx9M9gU6XE6ZWLhjPJ/Kll1GaKK+WPSwBw==
"@signalapp/mock-server@2.21.1":
version "2.21.1"
resolved "https://registry.yarnpkg.com/@signalapp/mock-server/-/mock-server-2.21.1.tgz#31ac756a8db0509cf6065b7c6b8139c7dc54c24d"
integrity sha512-pycdxIyv8/vPJSl5GZkTTbeFHVq3keefpfuqhVN6ZnP7UfKc0EJ5n3STcTN1V6AdNkdntK82pt47836ln9Wmrg==
dependencies:
"@signalapp/libsignal-client" "^0.24.0"
debug "^4.3.2"