Update backup protos

This commit is contained in:
automated-signal 2024-07-25 10:12:41 -05:00 committed by GitHub
parent 05aacc2c98
commit 6a49855e52
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 linkPreviews = 4;
bool notDiscoverableByPhoneNumber = 5; bool notDiscoverableByPhoneNumber = 5;
bool preferContactAvatars = 6; 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; repeated string preferredReactionEmoji = 8;
bool displayBadgesOnProfile = 9; bool displayBadgesOnProfile = 9;
bool keepMutedChatsArchived = 10; bool keepMutedChatsArchived = 10;
@ -305,15 +305,6 @@ message DistributionList {
repeated uint64 memberRecipientIds = 4; // generated recipient id 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 ChatItem {
message IncomingMessageDetails { message IncomingMessageDetails {
uint64 dateReceived = 1; uint64 dateReceived = 1;
@ -518,12 +509,6 @@ message ContactAttachment {
optional string organization = 7; optional string organization = 7;
} }
message DocumentMessage {
Text text = 1;
FilePointer document = 2;
repeated Reaction reactions = 3;
}
message StickerMessage { message StickerMessage {
Sticker sticker = 1; Sticker sticker = 1;
repeated Reaction reactions = 2; repeated Reaction reactions = 2;
@ -570,7 +555,7 @@ message MessageAttachment {
bool wasDownloaded = 3; bool wasDownloaded = 3;
// Cross-client identifier for this attachment among all attachments on the // Cross-client identifier for this attachment among all attachments on the
// owning message. See: SignalService.AttachmentPointer.clientUuid. // owning message. See: SignalService.AttachmentPointer.clientUuid.
optional bytes clientUuid = 4; optional bytes clientUuid = 4;
} }
message FilePointer { message FilePointer {
@ -583,7 +568,7 @@ message FilePointer {
optional uint32 cdnNumber = 2; optional uint32 cdnNumber = 2;
bytes key = 3; bytes key = 3;
bytes digest = 4; bytes digest = 4;
uint32 size = 5; uint64 size = 5;
// Fallback in case backup tier upload failed. // Fallback in case backup tier upload failed.
optional string transitCdnKey = 6; optional string transitCdnKey = 6;
optional uint32 transitCdnNumber = 7; optional uint32 transitCdnNumber = 7;
@ -759,7 +744,7 @@ message SimpleChatUpdate {
IDENTITY_VERIFIED = 3; IDENTITY_VERIFIED = 3;
IDENTITY_DEFAULT = 4; // marking as unverified IDENTITY_DEFAULT = 4; // marking as unverified
CHANGE_NUMBER = 5; CHANGE_NUMBER = 5;
BOOST_REQUEST = 6; RELEASE_CHANNEL_DONATION_REQUEST = 6;
END_SESSION = 7; END_SESSION = 7;
CHAT_SESSION_REFRESH = 8; CHAT_SESSION_REFRESH = 8;
BAD_DECRYPT = 9; BAD_DECRYPT = 9;
@ -774,7 +759,7 @@ message SimpleChatUpdate {
// For 1:1 chat updates only. // For 1:1 chat updates only.
// For group thread updates use GroupExpirationTimerUpdate. // For group thread updates use GroupExpirationTimerUpdate.
message ExpirationTimerChatUpdate { message ExpirationTimerChatUpdate {
uint32 expiresInMs = 1; // 0 means the expiration timer was disabled uint64 expiresInMs = 1; // 0 means the expiration timer was disabled
} }
message ProfileChangeChatUpdate { message ProfileChangeChatUpdate {
@ -1040,7 +1025,7 @@ message GroupV2MigrationDroppedMembersUpdate {
// For 1:1 timer updates, use ExpirationTimerChatUpdate. // For 1:1 timer updates, use ExpirationTimerChatUpdate.
message GroupExpirationTimerUpdate { 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; optional bytes updaterAci = 2;
} }
@ -1052,7 +1037,7 @@ message StickerPack {
message ChatStyle { message ChatStyle {
message Gradient { message Gradient {
uint32 angle = 1; // degrees uint32 angle = 1; // degrees
repeated uint32 colors = 2; repeated fixed32 colors = 2;
repeated float positions = 3; // percent from 0 to 1 repeated float positions = 3; // percent from 0 to 1
} }
@ -1060,7 +1045,7 @@ message ChatStyle {
uint32 id = 1; uint32 id = 1;
oneof color { oneof color {
uint32 solid = 2; fixed32 solid = 2;
Gradient gradient = 3; Gradient gradient = 3;
} }
} }
@ -1133,4 +1118,6 @@ message ChatStyle {
// See AccountSettings.customChatColors // See AccountSettings.customChatColors
uint32 customColorId = 5; 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. // Set at backup import time, exported as is.
wallpaperPhotoPointerBase64?: string; wallpaperPhotoPointerBase64?: string;
wallpaperPreset?: number; wallpaperPreset?: number;
dimWallpaperInDarkMode?: boolean;
discoveredUnregisteredAt?: number; discoveredUnregisteredAt?: number;
firstUnregisteredAt?: number; firstUnregisteredAt?: number;

View file

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

View file

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

View file

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

View file

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

View file

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