Update backup protos

This commit is contained in:
Fedor Indutny 2024-07-25 07:58:51 -07:00 committed by GitHub
parent 59d9807301
commit d627bf543e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 61 additions and 44 deletions

View file

@ -66,7 +66,7 @@ message AccountData {
bool linkPreviews = 4;
bool notDiscoverableByPhoneNumber = 5;
bool preferContactAvatars = 6;
uint32 universalExpireTimer = 7; // 0 means no universal expire timer.
uint32 universalExpireTimerSeconds = 7; // 0 means no universal expire timer.
repeated string preferredReactionEmoji = 8;
bool displayBadgesOnProfile = 9;
bool keepMutedChatsArchived = 10;
@ -305,15 +305,6 @@ message DistributionList {
repeated uint64 memberRecipientIds = 4; // generated recipient id
}
message Identity {
bytes serviceId = 1;
bytes identityKey = 2;
uint64 timestamp = 3;
bool firstUse = 4;
bool verified = 5;
bool nonblockingApproval = 6;
}
message ChatItem {
message IncomingMessageDetails {
uint64 dateReceived = 1;
@ -518,12 +509,6 @@ message ContactAttachment {
optional string organization = 7;
}
message DocumentMessage {
Text text = 1;
FilePointer document = 2;
repeated Reaction reactions = 3;
}
message StickerMessage {
Sticker sticker = 1;
repeated Reaction reactions = 2;
@ -570,7 +555,7 @@ message MessageAttachment {
bool wasDownloaded = 3;
// Cross-client identifier for this attachment among all attachments on the
// owning message. See: SignalService.AttachmentPointer.clientUuid.
optional bytes clientUuid = 4;
optional bytes clientUuid = 4;
}
message FilePointer {
@ -583,7 +568,7 @@ message FilePointer {
optional uint32 cdnNumber = 2;
bytes key = 3;
bytes digest = 4;
uint32 size = 5;
uint64 size = 5;
// Fallback in case backup tier upload failed.
optional string transitCdnKey = 6;
optional uint32 transitCdnNumber = 7;
@ -759,7 +744,7 @@ message SimpleChatUpdate {
IDENTITY_VERIFIED = 3;
IDENTITY_DEFAULT = 4; // marking as unverified
CHANGE_NUMBER = 5;
BOOST_REQUEST = 6;
RELEASE_CHANNEL_DONATION_REQUEST = 6;
END_SESSION = 7;
CHAT_SESSION_REFRESH = 8;
BAD_DECRYPT = 9;
@ -774,7 +759,7 @@ message SimpleChatUpdate {
// For 1:1 chat updates only.
// For group thread updates use GroupExpirationTimerUpdate.
message ExpirationTimerChatUpdate {
uint32 expiresInMs = 1; // 0 means the expiration timer was disabled
uint64 expiresInMs = 1; // 0 means the expiration timer was disabled
}
message ProfileChangeChatUpdate {
@ -1040,7 +1025,7 @@ message GroupV2MigrationDroppedMembersUpdate {
// For 1:1 timer updates, use ExpirationTimerChatUpdate.
message GroupExpirationTimerUpdate {
uint32 expiresInMs = 1; // 0 means the expiration timer was disabled
uint64 expiresInMs = 1; // 0 means the expiration timer was disabled
optional bytes updaterAci = 2;
}
@ -1052,7 +1037,7 @@ message StickerPack {
message ChatStyle {
message Gradient {
uint32 angle = 1; // degrees
repeated uint32 colors = 2;
repeated fixed32 colors = 2;
repeated float positions = 3; // percent from 0 to 1
}
@ -1060,7 +1045,7 @@ message ChatStyle {
uint32 id = 1;
oneof color {
uint32 solid = 2;
fixed32 solid = 2;
Gradient gradient = 3;
}
}
@ -1133,4 +1118,6 @@ message ChatStyle {
// See AccountSettings.customChatColors
uint32 customColorId = 5;
}
bool dimWallpaperInDarkMode = 7;
}

1
ts/model-types.d.ts vendored
View file

@ -336,6 +336,7 @@ export type ConversationAttributesType = {
// Set at backup import time, exported as is.
wallpaperPhotoPointerBase64?: string;
wallpaperPreset?: number;
dimWallpaperInDarkMode?: boolean;
discoveredUnregisteredAt?: number;
firstUnregisteredAt?: number;

View file

@ -360,6 +360,7 @@ export class BackupExportStream extends Readable {
wallpaperPreset: attributes.wallpaperPreset,
color: attributes.conversationColor,
customColorId: attributes.customColorId,
dimWallpaperInDarkMode: attributes.dimWallpaperInDarkMode,
}),
},
});
@ -554,7 +555,7 @@ export class BackupExportStream extends Readable {
storage.get('phoneNumberDiscoverability')
) === PhoneNumberDiscoverability.NotDiscoverable,
preferContactAvatars: storage.get('preferContactAvatars'),
universalExpireTimer: storage.get('universalExpireTimer'),
universalExpireTimerSeconds: storage.get('universalExpireTimer'),
preferredReactionEmoji,
displayBadgesOnProfile: storage.get('displayBadgesOnProfile'),
keepMutedChatsArchived: storage.get('keepMutedChatsArchived'),
@ -1174,7 +1175,10 @@ export class BackupExportStream extends Readable {
if (isExpirationTimerUpdate(message)) {
const expiresInSeconds = message.expirationTimerUpdate?.expireTimer;
const expiresInMs = (expiresInSeconds ?? 0) * 1000;
const expiresInMs =
expiresInSeconds == null
? 0
: DurationInSeconds.toMillis(expiresInSeconds);
const conversation = window.ConversationController.get(
message.conversationId
@ -1184,7 +1188,7 @@ export class BackupExportStream extends Readable {
const groupChatUpdate = new Backups.GroupChangeChatUpdate();
const timerUpdate = new Backups.GroupExpirationTimerUpdate();
timerUpdate.expiresInMs = expiresInMs;
timerUpdate.expiresInMs = Long.fromNumber(expiresInMs);
const sourceServiceId = message.expirationTimerUpdate?.sourceServiceId;
if (sourceServiceId && Aci.parseFromServiceIdString(sourceServiceId)) {
@ -1212,7 +1216,7 @@ export class BackupExportStream extends Readable {
}
const expirationTimerChange = new Backups.ExpirationTimerChatUpdate();
expirationTimerChange.expiresInMs = expiresInMs;
expirationTimerChange.expiresInMs = Long.fromNumber(expiresInMs);
updateMessage.expirationTimerChange = expirationTimerChange;
@ -2309,6 +2313,10 @@ export class BackupExportStream extends Readable {
wallpaperPreset: window.storage.get('defaultWallpaperPreset'),
color: defaultColor?.color,
customColorId: defaultColor?.customColorData?.id,
dimWallpaperInDarkMode: window.storage.get(
'defaultDimWallpaperInDarkMode',
false
),
});
}
@ -2317,8 +2325,11 @@ export class BackupExportStream extends Readable {
wallpaperPreset,
color,
customColorId,
dimWallpaperInDarkMode,
}: LocalChatStyle): Backups.IChatStyle {
const result: Backups.IChatStyle = {};
const result: Backups.IChatStyle = {
dimWallpaperInDarkMode,
};
if (Bytes.isNotEmpty(wallpaperPhotoPointer)) {
result.wallpaperPhoto = Backups.FilePointer.decode(wallpaperPhotoPointer);

View file

@ -548,10 +548,10 @@ export class BackupImportStream extends Writable {
'preferContactAvatars',
accountSettings?.preferContactAvatars === true
);
if (accountSettings?.universalExpireTimer) {
if (accountSettings?.universalExpireTimerSeconds) {
await storage.put(
'universalExpireTimer',
accountSettings.universalExpireTimer
accountSettings.universalExpireTimerSeconds
);
}
await storage.put(
@ -648,6 +648,12 @@ export class BackupImportStream extends Writable {
defaultChatStyle.wallpaperPreset
);
}
if (defaultChatStyle.dimWallpaperInDarkMode != null) {
await window.storage.put(
'defaultDimWallpaperInDarkMode',
defaultChatStyle.dimWallpaperInDarkMode
);
}
this.updateConversation(me);
}
@ -1012,6 +1018,9 @@ export class BackupImportStream extends Writable {
conversation.customColor = chatStyle.customColorData.value;
conversation.customColorId = chatStyle.customColorData.id;
}
if (chatStyle.dimWallpaperInDarkMode != null) {
conversation.dimWallpaperInDarkMode = chatStyle.dimWallpaperInDarkMode;
}
this.updateConversation(conversation);
@ -1731,10 +1740,9 @@ export class BackupImportStream extends Writable {
const { expiresInMs } = updateMessage.expirationTimerChange;
const sourceServiceId = author?.serviceId ?? aboutMe.aci;
const expireTimer =
isNumber(expiresInMs) && expiresInMs
? DurationInSeconds.fromMillis(expiresInMs)
: DurationInSeconds.fromSeconds(0);
const expireTimer = DurationInSeconds.fromMillis(
expiresInMs?.toNumber() ?? 0
);
return {
message: {
@ -2359,10 +2367,9 @@ export class BackupImportStream extends Writable {
);
}
const sourceServiceId = fromAciObject(Aci.fromUuidBytes(updaterAci));
const expireTimer =
isNumber(expiresInMs) && expiresInMs
? DurationInSeconds.fromMillis(expiresInMs)
: undefined;
const expireTimer = expiresInMs
? DurationInSeconds.fromMillis(expiresInMs.toNumber())
: undefined;
additionalMessages.push({
type: 'timer-notification',
sourceServiceId,
@ -2483,9 +2490,10 @@ export class BackupImportStream extends Writable {
return {
type: 'delivery-issue',
};
case Type.BOOST_REQUEST:
case Type.RELEASE_CHANNEL_DONATION_REQUEST:
log.warn('backups: dropping boost request from release notes');
return undefined;
// TODO(indutny): REPORTED_SPAM
case Type.PAYMENTS_ACTIVATED:
return {
payment: {
@ -2596,11 +2604,13 @@ export class BackupImportStream extends Writable {
wallpaperPreset: undefined,
color: 'ultramarine',
customColorData: undefined,
dimWallpaperInDarkMode: undefined,
};
}
let wallpaperPhotoPointer: Uint8Array | undefined;
let wallpaperPreset: number | undefined;
const dimWallpaperInDarkMode = dropNull(chatStyle.dimWallpaperInDarkMode);
if (chatStyle.wallpaperPhoto) {
wallpaperPhotoPointer = Backups.FilePointer.encode(
@ -2700,7 +2710,13 @@ export class BackupImportStream extends Writable {
customColorData = entry;
}
return { wallpaperPhotoPointer, wallpaperPreset, color, customColorData };
return {
wallpaperPhotoPointer,
wallpaperPreset,
color,
customColorData,
dimWallpaperInDarkMode,
};
}
}

View file

@ -14,4 +14,5 @@ export type LocalChatStyle = Readonly<{
wallpaperPreset: number | undefined;
color: ConversationColorType | undefined;
customColorId: string | undefined;
dimWallpaperInDarkMode: boolean | undefined;
}>;

View file

@ -105,7 +105,7 @@ export function convertFilePointerToAttachment(
cdnNumber: transitCdnNumber ?? undefined,
key: key?.length ? Bytes.toBase64(key) : undefined,
digest: digest?.length ? Bytes.toBase64(digest) : undefined,
size: size ?? 0,
size: size?.toNumber() ?? 0,
backupLocator: mediaName
? {
mediaName,
@ -401,7 +401,7 @@ function getBackupLocator(attachment: AttachmentDownloadableFromBackupTier) {
cdnNumber: attachment.backupLocator.cdnNumber,
digest: Bytes.fromBase64(attachment.digest),
key: Bytes.fromBase64(attachment.key),
size: attachment.size,
size: Long.fromNumber(attachment.size),
transitCdnKey: attachment.cdnKey,
transitCdnNumber: attachment.cdnNumber,
});

View file

@ -75,7 +75,7 @@ describe('convertFilePointerToAttachment', () => {
backupLocator: new Backups.FilePointer.BackupLocator({
mediaName: 'mediaName',
cdnNumber: 3,
size: 128,
size: Long.fromNumber(128),
key: Bytes.fromString('key'),
digest: Bytes.fromString('digest'),
transitCdnKey: 'transitCdnKey',
@ -213,7 +213,7 @@ const defaultBackupLocator = new Backups.FilePointer.BackupLocator({
cdnNumber: null,
key: Bytes.fromBase64('key'),
digest: Bytes.fromBase64('digest'),
size: 100,
size: Long.fromNumber(100),
transitCdnKey: 'cdnKey',
transitCdnNumber: 2,
});

View file

@ -68,6 +68,7 @@ export type StorageAccessType = {
// Not used UI, stored as is when imported from backup.
defaultWallpaperPhotoPointer: Uint8Array;
defaultWallpaperPreset: number;
defaultDimWallpaperInDarkMode: boolean;
customColors: CustomColorsItemType;
device_name: string;