Merge pull request #1105 from Mikunj/fix-reset-registration

Fix corner cases for registration reset
pull/1113/head
Audric Ackermann 5 years ago committed by GitHub
commit 5564bfa134
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2750,16 +2750,9 @@ async function removeAll() {
db.serialize(() => {
promise = Promise.all([
db.run('BEGIN TRANSACTION;'),
...getRemoveConfigurationPromises(),
db.run('DELETE FROM conversations;'),
db.run('DELETE FROM identityKeys;'),
db.run('DELETE FROM items;'),
db.run('DELETE FROM messages;'),
db.run('DELETE FROM preKeys;'),
db.run('DELETE FROM sessions;'),
db.run('DELETE FROM signedPreKeys;'),
db.run('DELETE FROM unprocessed;'),
db.run('DELETE FROM contactPreKeys;'),
db.run('DELETE FROM contactSignedPreKeys;'),
db.run('DELETE FROM attachment_downloads;'),
db.run('DELETE FROM messages_fts;'),
db.run('COMMIT TRANSACTION;'),
@ -2769,6 +2762,22 @@ async function removeAll() {
await promise;
}
function getRemoveConfigurationPromises() {
return [
db.run('DELETE FROM identityKeys;'),
db.run('DELETE FROM items;'),
db.run('DELETE FROM preKeys;'),
db.run('DELETE FROM sessions;'),
db.run('DELETE FROM signedPreKeys;'),
db.run('DELETE FROM unprocessed;'),
db.run('DELETE FROM contactPreKeys;'),
db.run('DELETE FROM contactSignedPreKeys;'),
db.run('DELETE FROM servers;'),
db.run('DELETE FROM lastHashes;'),
db.run('DELETE FROM seenMessages;'),
];
}
// Anything that isn't user-visible data
async function removeAllConfiguration() {
let promise;
@ -2776,14 +2785,7 @@ async function removeAllConfiguration() {
db.serialize(() => {
promise = Promise.all([
db.run('BEGIN TRANSACTION;'),
db.run('DELETE FROM identityKeys;'),
db.run('DELETE FROM items;'),
db.run('DELETE FROM preKeys;'),
db.run('DELETE FROM sessions;'),
db.run('DELETE FROM signedPreKeys;'),
db.run('DELETE FROM unprocessed;'),
db.run('DELETE FROM contactPreKeys;'),
db.run('DELETE FROM contactSignedPreKeys;'),
...getRemoveConfigurationPromises(),
db.run('COMMIT TRANSACTION;'),
]);
});

@ -713,13 +713,8 @@ export class RegistrationTabs extends React.Component<{}, State> {
}
private async resetRegistration() {
await window.Signal.Data.removeAllIdentityKeys();
await window.Signal.Data.removeAllPrivateConversations();
window.Whisper.Registration.remove();
// Do not remove all items since they are only set
// at startup.
window.textsecure.storage.remove('identityKey');
window.textsecure.storage.remove('secondaryDeviceStatus');
await window.Signal.Data.removeAll();
await window.storage.fetch();
window.ConversationController.reset();
await window.ConversationController.load();
window.Whisper.RotateSignedPreKeyListener.stop(window.Whisper.events);

Loading…
Cancel
Save