Skip to content

Commit

Permalink
Fix backup validation
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Apr 18, 2024
1 parent ec2a17a commit 187fe08
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions ts/services/backups/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type GetRecipientIdOptionsType =
}>;

export class BackupExportStream extends Readable {
private readonly backupTimeMs = getSafeLongFromTimestamp(Date.now());
private readonly convoIdToRecipientId = new Map<string, number>();
private buffers = new Array<Uint8Array>();
private nextRecipientId = 0;
Expand Down Expand Up @@ -102,7 +103,7 @@ export class BackupExportStream extends Readable {
this.push(
Backups.BackupInfo.encodeDelimited({
version: Long.fromNumber(BACKUP_VERSION),
backupTimeMs: getSafeLongFromTimestamp(Date.now()),
backupTimeMs: this.backupTimeMs,
}).finish()
);

Expand Down Expand Up @@ -547,18 +548,26 @@ export class BackupExportStream extends Readable {
return undefined;
}

let expireStartDate: Long | undefined;
let expiresInMs: Long | undefined;
if (
message.expireTimer != null &&
message.expirationStartTimestamp != null
) {
expireStartDate = getSafeLongFromTimestamp(
message.expirationStartTimestamp
);
expiresInMs = Long.fromNumber(
DurationInSeconds.toMillis(message.expireTimer)
);
}

const result: Backups.IChatItem = {
chatId,
authorId,
dateSent: getSafeLongFromTimestamp(message.sent_at),
expireStartDate:
message.expirationStartTimestamp != null
? getSafeLongFromTimestamp(message.expirationStartTimestamp)
: null,
expiresInMs:
message.expireTimer != null
? Long.fromNumber(DurationInSeconds.toMillis(message.expireTimer))
: null,
expireStartDate,
expiresInMs,
revisions: [],
sms: false,
standardMessage: {
Expand Down

0 comments on commit 187fe08

Please sign in to comment.