No more type passed to removeAllConfiguration; keep more UI keys
This commit is contained in:
parent
046a3c4849
commit
d7177516c1
7 changed files with 31 additions and 51 deletions
|
@ -50,7 +50,6 @@ import type {
|
||||||
UnprocessedUpdateType,
|
UnprocessedUpdateType,
|
||||||
CompatPreKeyType,
|
CompatPreKeyType,
|
||||||
} from './textsecure/Types.d';
|
} from './textsecure/Types.d';
|
||||||
import type { RemoveAllConfiguration } from './types/RemoveAllConfiguration';
|
|
||||||
import type { ServiceIdString, PniString, AciString } from './types/ServiceId';
|
import type { ServiceIdString, PniString, AciString } from './types/ServiceId';
|
||||||
import { isServiceIdString, ServiceIdKind } from './types/ServiceId';
|
import { isServiceIdString, ServiceIdKind } from './types/ServiceId';
|
||||||
import type { Address } from './types/Address';
|
import type { Address } from './types/Address';
|
||||||
|
@ -2699,8 +2698,8 @@ export class SignalProtocolStore extends EventEmitter {
|
||||||
this.emit('removeAllData');
|
this.emit('removeAllData');
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeAllConfiguration(mode: RemoveAllConfiguration): Promise<void> {
|
async removeAllConfiguration(): Promise<void> {
|
||||||
await window.Signal.Data.removeAllConfiguration(mode);
|
await window.Signal.Data.removeAllConfiguration();
|
||||||
await this.hydrateCaches();
|
await this.hydrateCaches();
|
||||||
|
|
||||||
window.storage.reset();
|
window.storage.reset();
|
||||||
|
|
|
@ -137,7 +137,6 @@ import {
|
||||||
} from './util/handleRetry';
|
} from './util/handleRetry';
|
||||||
import { themeChanged } from './shims/themeChanged';
|
import { themeChanged } from './shims/themeChanged';
|
||||||
import { createIPCEvents } from './util/createIPCEvents';
|
import { createIPCEvents } from './util/createIPCEvents';
|
||||||
import { RemoveAllConfiguration } from './types/RemoveAllConfiguration';
|
|
||||||
import type { ServiceIdString } from './types/ServiceId';
|
import type { ServiceIdString } from './types/ServiceId';
|
||||||
import { ServiceIdKind, isServiceIdString } from './types/ServiceId';
|
import { ServiceIdKind, isServiceIdString } from './types/ServiceId';
|
||||||
import { isAciString } from './util/isAciString';
|
import { isAciString } from './util/isAciString';
|
||||||
|
@ -849,7 +848,7 @@ export async function startApp(): Promise<void> {
|
||||||
log.warn(
|
log.warn(
|
||||||
`This instance has not been used for 30 days. Last heartbeat: ${lastHeartbeat}. Last startup: ${previousLastStartup}.`
|
`This instance has not been used for 30 days. Last heartbeat: ${lastHeartbeat}. Last startup: ${previousLastStartup}.`
|
||||||
);
|
);
|
||||||
await unlinkAndDisconnect(RemoveAllConfiguration.Soft);
|
await unlinkAndDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start heartbeat timer
|
// Start heartbeat timer
|
||||||
|
@ -1343,7 +1342,7 @@ export async function startApp(): Promise<void> {
|
||||||
});
|
});
|
||||||
|
|
||||||
window.Whisper.events.on('unlinkAndDisconnect', () => {
|
window.Whisper.events.on('unlinkAndDisconnect', () => {
|
||||||
void unlinkAndDisconnect(RemoveAllConfiguration.Full);
|
void unlinkAndDisconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function runStorageService() {
|
async function runStorageService() {
|
||||||
|
@ -1784,7 +1783,7 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
if (!window.textsecure.storage.user.getAci()) {
|
if (!window.textsecure.storage.user.getAci()) {
|
||||||
log.error('UUID not captured during registration, unlinking');
|
log.error('UUID not captured during registration, unlinking');
|
||||||
return unlinkAndDisconnect(RemoveAllConfiguration.Full);
|
return unlinkAndDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connectCount === 1) {
|
if (connectCount === 1) {
|
||||||
|
@ -1804,7 +1803,7 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
if (!window.textsecure.storage.user.getPni()) {
|
if (!window.textsecure.storage.user.getPni()) {
|
||||||
log.error('PNI not captured during registration, unlinking softly');
|
log.error('PNI not captured during registration, unlinking softly');
|
||||||
return unlinkAndDisconnect(RemoveAllConfiguration.Soft);
|
return unlinkAndDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstRun === true && deviceId !== 1) {
|
if (firstRun === true && deviceId !== 1) {
|
||||||
|
@ -2892,9 +2891,7 @@ export async function startApp(): Promise<void> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unlinkAndDisconnect(
|
async function unlinkAndDisconnect(): Promise<void> {
|
||||||
mode: RemoveAllConfiguration
|
|
||||||
): Promise<void> {
|
|
||||||
window.Whisper.events.trigger('unauthorized');
|
window.Whisper.events.trigger('unauthorized');
|
||||||
|
|
||||||
log.warn(
|
log.warn(
|
||||||
|
@ -2934,7 +2931,7 @@ export async function startApp(): Promise<void> {
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info(`unlinkAndDisconnect: removing configuration, mode ${mode}`);
|
log.info('unlinkAndDisconnect: removing configuration');
|
||||||
|
|
||||||
// First, make changes to conversations in memory
|
// First, make changes to conversations in memory
|
||||||
window.getConversations().forEach(conversation => {
|
window.getConversations().forEach(conversation => {
|
||||||
|
@ -2948,7 +2945,7 @@ export async function startApp(): Promise<void> {
|
||||||
await window.Signal.Data.getItemById('manifestVersion');
|
await window.Signal.Data.getItemById('manifestVersion');
|
||||||
|
|
||||||
// Finally, conversations in the database, and delete all config tables
|
// Finally, conversations in the database, and delete all config tables
|
||||||
await window.textsecure.storage.protocol.removeAllConfiguration(mode);
|
await window.textsecure.storage.protocol.removeAllConfiguration();
|
||||||
|
|
||||||
// These three bits of data are important to ensure that the app loads up
|
// These three bits of data are important to ensure that the app loads up
|
||||||
// the conversation list, instead of showing just the QR code screen.
|
// the conversation list, instead of showing just the QR code screen.
|
||||||
|
@ -3001,7 +2998,7 @@ export async function startApp(): Promise<void> {
|
||||||
error instanceof HTTPError &&
|
error instanceof HTTPError &&
|
||||||
(error.code === 401 || error.code === 403)
|
(error.code === 401 || error.code === 403)
|
||||||
) {
|
) {
|
||||||
void unlinkAndDisconnect(RemoveAllConfiguration.Full);
|
void unlinkAndDisconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import type { QualifiedAddressStringType } from '../types/QualifiedAddress';
|
||||||
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
||||||
import type { AciString, PniString, ServiceIdString } from '../types/ServiceId';
|
import type { AciString, PniString, ServiceIdString } from '../types/ServiceId';
|
||||||
import type { BadgeType } from '../badges/types';
|
import type { BadgeType } from '../badges/types';
|
||||||
import type { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
|
||||||
import type { LoggerType } from '../types/Logging';
|
import type { LoggerType } from '../types/Logging';
|
||||||
import type { ReadStatus } from '../messages/MessageReadStatus';
|
import type { ReadStatus } from '../messages/MessageReadStatus';
|
||||||
import type { RawBodyRange } from '../types/BodyRange';
|
import type { RawBodyRange } from '../types/BodyRange';
|
||||||
|
@ -794,7 +793,7 @@ export type DataInterface = {
|
||||||
countStoryReadsByConversation(conversationId: string): Promise<number>;
|
countStoryReadsByConversation(conversationId: string): Promise<number>;
|
||||||
|
|
||||||
removeAll: () => Promise<void>;
|
removeAll: () => Promise<void>;
|
||||||
removeAllConfiguration: (type?: RemoveAllConfiguration) => Promise<void>;
|
removeAllConfiguration: () => Promise<void>;
|
||||||
eraseStorageServiceState: () => Promise<void>;
|
eraseStorageServiceState: () => Promise<void>;
|
||||||
|
|
||||||
getMessagesNeedingUpgrade: (
|
getMessagesNeedingUpgrade: (
|
||||||
|
|
|
@ -44,12 +44,10 @@ import { consoleLogger } from '../util/consoleLogger';
|
||||||
import { dropNull } from '../util/dropNull';
|
import { dropNull } from '../util/dropNull';
|
||||||
import { isNormalNumber } from '../util/isNormalNumber';
|
import { isNormalNumber } from '../util/isNormalNumber';
|
||||||
import { isNotNil } from '../util/isNotNil';
|
import { isNotNil } from '../util/isNotNil';
|
||||||
import { missingCaseError } from '../util/missingCaseError';
|
|
||||||
import { parseIntOrThrow } from '../util/parseIntOrThrow';
|
import { parseIntOrThrow } from '../util/parseIntOrThrow';
|
||||||
import * as durations from '../util/durations';
|
import * as durations from '../util/durations';
|
||||||
import { formatCountForLogging } from '../logging/formatCountForLogging';
|
import { formatCountForLogging } from '../logging/formatCountForLogging';
|
||||||
import type { ConversationColorType, CustomColorType } from '../types/Colors';
|
import type { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||||
import { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
|
||||||
import type { BadgeType, BadgeImageType } from '../badges/types';
|
import type { BadgeType, BadgeImageType } from '../badges/types';
|
||||||
import { parseBadgeCategory } from '../badges/BadgeCategory';
|
import { parseBadgeCategory } from '../badges/BadgeCategory';
|
||||||
import { parseBadgeImageTheme } from '../badges/BadgeImageTheme';
|
import { parseBadgeImageTheme } from '../badges/BadgeImageTheme';
|
||||||
|
@ -5682,9 +5680,7 @@ async function removeAll(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anything that isn't user-visible data
|
// Anything that isn't user-visible data
|
||||||
async function removeAllConfiguration(
|
async function removeAllConfiguration(): Promise<void> {
|
||||||
mode = RemoveAllConfiguration.Full
|
|
||||||
): Promise<void> {
|
|
||||||
const db = await getWritableInstance();
|
const db = await getWritableInstance();
|
||||||
|
|
||||||
db.transaction(() => {
|
db.transaction(() => {
|
||||||
|
@ -5704,13 +5700,6 @@ async function removeAllConfiguration(
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mode === RemoveAllConfiguration.Full) {
|
|
||||||
db.exec(
|
|
||||||
`
|
|
||||||
DELETE FROM items;
|
|
||||||
`
|
|
||||||
);
|
|
||||||
} else if (mode === RemoveAllConfiguration.Soft) {
|
|
||||||
const itemIds: ReadonlyArray<string> = db
|
const itemIds: ReadonlyArray<string> = db
|
||||||
.prepare<EmptyQuery>('SELECT id FROM items')
|
.prepare<EmptyQuery>('SELECT id FROM items')
|
||||||
.pluck(true)
|
.pluck(true)
|
||||||
|
@ -5722,9 +5711,6 @@ async function removeAllConfiguration(
|
||||||
removeById(db, 'items', id);
|
removeById(db, 'items', id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw missingCaseError(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
db.exec(
|
db.exec(
|
||||||
`
|
`
|
||||||
|
|
|
@ -24,7 +24,6 @@ import ProvisioningCipher from './ProvisioningCipher';
|
||||||
import type { IncomingWebSocketRequest } from './WebsocketResources';
|
import type { IncomingWebSocketRequest } from './WebsocketResources';
|
||||||
import createTaskWithTimeout from './TaskWithTimeout';
|
import createTaskWithTimeout from './TaskWithTimeout';
|
||||||
import * as Bytes from '../Bytes';
|
import * as Bytes from '../Bytes';
|
||||||
import { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
|
||||||
import * as Errors from '../types/errors';
|
import * as Errors from '../types/errors';
|
||||||
import { senderCertificateService } from '../services/senderCertificate';
|
import { senderCertificateService } from '../services/senderCertificate';
|
||||||
import {
|
import {
|
||||||
|
@ -1043,10 +1042,8 @@ export default class AccountManager extends EventTarget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.info('createAccount: Erasing configuration (soft)');
|
log.info('createAccount: Erasing configuration');
|
||||||
await storage.protocol.removeAllConfiguration(
|
await storage.protocol.removeAllConfiguration();
|
||||||
RemoveAllConfiguration.Soft
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await senderCertificateService.clear();
|
await senderCertificateService.clear();
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
export enum RemoveAllConfiguration {
|
|
||||||
Full = 'Full',
|
|
||||||
Soft = 'Soft',
|
|
||||||
}
|
|
|
@ -11,6 +11,7 @@ export type ThemeSettingType = z.infer<typeof themeSettingSchema>;
|
||||||
export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
|
export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
|
||||||
'always-relay-calls',
|
'always-relay-calls',
|
||||||
'audio-notification',
|
'audio-notification',
|
||||||
|
'audioMessage',
|
||||||
'auto-download-update',
|
'auto-download-update',
|
||||||
'badge-count-muted-conversations',
|
'badge-count-muted-conversations',
|
||||||
'call-ringtone-notification',
|
'call-ringtone-notification',
|
||||||
|
@ -18,8 +19,13 @@ export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
|
||||||
'customColors',
|
'customColors',
|
||||||
'defaultConversationColor',
|
'defaultConversationColor',
|
||||||
'existingOnboardingStoryMessageIds',
|
'existingOnboardingStoryMessageIds',
|
||||||
|
'formattingWarningShown',
|
||||||
|
'hasCompletedSafetyNumberOnboarding',
|
||||||
|
'hasCompletedUsernameLinkOnboarding',
|
||||||
'hide-menu-bar',
|
'hide-menu-bar',
|
||||||
'incoming-call-notification',
|
'incoming-call-notification',
|
||||||
|
'localeOverride',
|
||||||
|
'navTabsCollapsed',
|
||||||
'notification-draw-attention',
|
'notification-draw-attention',
|
||||||
'notification-setting',
|
'notification-setting',
|
||||||
'pinnedConversationIds',
|
'pinnedConversationIds',
|
||||||
|
@ -29,11 +35,14 @@ export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
|
||||||
'preferredLeftPaneWidth',
|
'preferredLeftPaneWidth',
|
||||||
'preferredReactionEmoji',
|
'preferredReactionEmoji',
|
||||||
'previousAudioDeviceModule',
|
'previousAudioDeviceModule',
|
||||||
|
'sendEditWarningShown',
|
||||||
|
'sent-media-quality',
|
||||||
'showStickerPickerHint',
|
'showStickerPickerHint',
|
||||||
'showStickersIntroduction',
|
'showStickersIntroduction',
|
||||||
'skinTone',
|
'skinTone',
|
||||||
'spell-check',
|
'spell-check',
|
||||||
'system-tray-setting',
|
'system-tray-setting',
|
||||||
|
'textFormatting',
|
||||||
'theme-setting',
|
'theme-setting',
|
||||||
'zoomFactor',
|
'zoomFactor',
|
||||||
];
|
];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue