Stop round-tripping wallpaper data
This commit is contained in:
parent
a5ed182c01
commit
b5ce45aeed
5 changed files with 201 additions and 12 deletions
|
@ -3738,13 +3738,25 @@ export class BackupImportStream extends Writable {
|
||||||
autoBubbleColor = true;
|
autoBubbleColor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We only roundtrip wallpaper info in tests since it is not synced in storage service
|
||||||
|
const shouldImportWallpaper = isTestOrMockEnvironment();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
wallpaperPhotoPointer,
|
|
||||||
wallpaperPreset,
|
|
||||||
color,
|
color,
|
||||||
customColorData,
|
customColorData,
|
||||||
dimWallpaperInDarkMode,
|
...(shouldImportWallpaper
|
||||||
|
? {
|
||||||
autoBubbleColor,
|
autoBubbleColor,
|
||||||
|
wallpaperPhotoPointer,
|
||||||
|
wallpaperPreset,
|
||||||
|
dimWallpaperInDarkMode,
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
autoBubbleColor: undefined,
|
||||||
|
wallpaperPhotoPointer: undefined,
|
||||||
|
wallpaperPreset: undefined,
|
||||||
|
dimWallpaperInDarkMode: undefined,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
41
ts/sql/migrations/1410-remove-wallpaper.ts
Normal file
41
ts/sql/migrations/1410-remove-wallpaper.ts
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright 2025 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import type { LoggerType } from '../../types/Logging';
|
||||||
|
import { type WritableDB } from '../Interface';
|
||||||
|
|
||||||
|
export const version = 1410;
|
||||||
|
|
||||||
|
export function updateToSchemaVersion1410(
|
||||||
|
currentVersion: number,
|
||||||
|
db: WritableDB,
|
||||||
|
logger: LoggerType
|
||||||
|
): void {
|
||||||
|
if (currentVersion >= 1410) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.transaction(() => {
|
||||||
|
db.exec(`
|
||||||
|
UPDATE conversations
|
||||||
|
SET json = json_remove(json,
|
||||||
|
'$.wallpaperPreset',
|
||||||
|
'$.wallpaperPhotoPointerBase64',
|
||||||
|
'$.dimWallpaperInDarkMode',
|
||||||
|
'$.autoBubbleColor'
|
||||||
|
);
|
||||||
|
|
||||||
|
DELETE FROM items
|
||||||
|
WHERE id IN (
|
||||||
|
'defaultWallpaperPhotoPointer',
|
||||||
|
'defaultWallpaperPreset',
|
||||||
|
'defaultDimWallpaperInDarkMode',
|
||||||
|
'defaultAutoBubbleColor'
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
|
||||||
|
db.pragma('user_version = 1410');
|
||||||
|
})();
|
||||||
|
|
||||||
|
logger.info('updateToSchemaVersion1410: success!');
|
||||||
|
}
|
|
@ -115,10 +115,11 @@ import { updateToSchemaVersion1360 } from './1360-attachments';
|
||||||
import { updateToSchemaVersion1370 } from './1370-message-attachment-indexes';
|
import { updateToSchemaVersion1370 } from './1370-message-attachment-indexes';
|
||||||
import { updateToSchemaVersion1380 } from './1380-donation-receipts';
|
import { updateToSchemaVersion1380 } from './1380-donation-receipts';
|
||||||
import { updateToSchemaVersion1390 } from './1390-attachment-download-keys';
|
import { updateToSchemaVersion1390 } from './1390-attachment-download-keys';
|
||||||
|
import { updateToSchemaVersion1400 } from './1400-simplify-receipts';
|
||||||
import {
|
import {
|
||||||
updateToSchemaVersion1400,
|
updateToSchemaVersion1410,
|
||||||
version as MAX_VERSION,
|
version as MAX_VERSION,
|
||||||
} from './1400-simplify-receipts';
|
} from './1410-remove-wallpaper';
|
||||||
|
|
||||||
import { DataWriter } from '../Server';
|
import { DataWriter } from '../Server';
|
||||||
|
|
||||||
|
@ -2113,6 +2114,7 @@ export const SCHEMA_VERSIONS = [
|
||||||
updateToSchemaVersion1390,
|
updateToSchemaVersion1390,
|
||||||
|
|
||||||
updateToSchemaVersion1400,
|
updateToSchemaVersion1400,
|
||||||
|
updateToSchemaVersion1410,
|
||||||
];
|
];
|
||||||
|
|
||||||
export class DBVersionFromFutureError extends Error {
|
export class DBVersionFromFutureError extends Error {
|
||||||
|
|
133
ts/test-node/sql/migration_1410_test.ts
Normal file
133
ts/test-node/sql/migration_1410_test.ts
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
// Copyright 2025 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { assert } from 'chai';
|
||||||
|
|
||||||
|
import { type WritableDB } from '../../sql/Interface';
|
||||||
|
import { createDB, updateToVersion, insertData, getTableData } from './helpers';
|
||||||
|
import { createOrUpdate, getById } from '../../sql/util';
|
||||||
|
|
||||||
|
describe('SQL/updateToSchemaVersion1410', () => {
|
||||||
|
let db: WritableDB;
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
db.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
db = createDB();
|
||||||
|
updateToVersion(db, 1400);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deletes conversation wallpaper data if exists', () => {
|
||||||
|
const convos = [
|
||||||
|
{
|
||||||
|
id: 'convo-1',
|
||||||
|
expireTimerVersion: 1,
|
||||||
|
json: {
|
||||||
|
wallpaperPreset: 42,
|
||||||
|
wallpaperPhotoPointerBase64: 'base64',
|
||||||
|
dimWallpaperInDarkMode: false,
|
||||||
|
autoBubbleColor: true,
|
||||||
|
profileName: 'Alice',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'convo-2',
|
||||||
|
expireTimerVersion: 3,
|
||||||
|
json: {
|
||||||
|
wallpaperPreset: 42,
|
||||||
|
wallpaperPhotoPointerBase64: 'base64',
|
||||||
|
profileName: 'Bob',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'convo-3',
|
||||||
|
expireTimerVersion: 4,
|
||||||
|
json: {
|
||||||
|
profileName: 'Charlie',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
insertData(db, 'conversations', convos);
|
||||||
|
updateToVersion(db, 1410);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(getTableData(db, 'conversations'), [
|
||||||
|
{
|
||||||
|
id: 'convo-1',
|
||||||
|
expireTimerVersion: 1,
|
||||||
|
json: {
|
||||||
|
profileName: 'Alice',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'convo-2',
|
||||||
|
expireTimerVersion: 3,
|
||||||
|
json: {
|
||||||
|
profileName: 'Bob',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'convo-3',
|
||||||
|
expireTimerVersion: 4,
|
||||||
|
json: {
|
||||||
|
profileName: 'Charlie',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deletes default wallpaper data if exists', () => {
|
||||||
|
const items = [
|
||||||
|
{
|
||||||
|
id: 'defaultWallpaperPhotoPointer',
|
||||||
|
value: JSON.stringify(new Uint8Array([1, 2, 3])),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'defaultWallpaperPreset',
|
||||||
|
value: 12,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'defaultDimWallpaperInDarkMode',
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'defaultAutoBubbleColor',
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'otherItem',
|
||||||
|
value: 'otherItem-shouldBePreserved',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const item of items) {
|
||||||
|
createOrUpdate(db, 'items', { id: item.id, value: item });
|
||||||
|
}
|
||||||
|
updateToVersion(db, 1410);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
getById(db, 'items', 'defaultWallpaperPhotoPointer'),
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
assert.deepStrictEqual(getById(db, 'items', 'otherItem'), {
|
||||||
|
id: 'otherItem',
|
||||||
|
value: {
|
||||||
|
id: 'otherItem',
|
||||||
|
value: 'otherItem-shouldBePreserved',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
assert.deepStrictEqual(getTableData(db, 'items'), [
|
||||||
|
{
|
||||||
|
id: 'otherItem',
|
||||||
|
json: {
|
||||||
|
id: 'otherItem',
|
||||||
|
value: {
|
||||||
|
id: 'otherItem',
|
||||||
|
value: 'otherItem-shouldBePreserved',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
13
ts/types/Storage.d.ts
vendored
13
ts/types/Storage.d.ts
vendored
|
@ -78,12 +78,6 @@ export type StorageAccessType = {
|
||||||
blocked: ReadonlyArray<string>;
|
blocked: ReadonlyArray<string>;
|
||||||
defaultConversationColor: DefaultConversationColorType;
|
defaultConversationColor: DefaultConversationColorType;
|
||||||
|
|
||||||
// Not used UI, stored as is when imported from backup.
|
|
||||||
defaultWallpaperPhotoPointer: Uint8Array;
|
|
||||||
defaultWallpaperPreset: number;
|
|
||||||
defaultDimWallpaperInDarkMode: boolean;
|
|
||||||
defaultAutoBubbleColor: boolean;
|
|
||||||
|
|
||||||
customColors: CustomColorsItemType;
|
customColors: CustomColorsItemType;
|
||||||
device_name: string;
|
device_name: string;
|
||||||
existingOnboardingStoryMessageIds: ReadonlyArray<string> | undefined;
|
existingOnboardingStoryMessageIds: ReadonlyArray<string> | undefined;
|
||||||
|
@ -250,6 +244,13 @@ export type StorageAccessType = {
|
||||||
|
|
||||||
avatarsHaveBeenMigrated: boolean;
|
avatarsHaveBeenMigrated: boolean;
|
||||||
|
|
||||||
|
// Test-only
|
||||||
|
// Not used UI, stored as is when imported from backup during tests
|
||||||
|
defaultWallpaperPhotoPointer: Uint8Array;
|
||||||
|
defaultWallpaperPreset: number;
|
||||||
|
defaultDimWallpaperInDarkMode: boolean;
|
||||||
|
defaultAutoBubbleColor: boolean;
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
'challenge:retry-message-ids': never;
|
'challenge:retry-message-ids': never;
|
||||||
nextSignedKeyRotationTime: number;
|
nextSignedKeyRotationTime: number;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue