Improve check during message export
This commit is contained in:
parent
a769429b36
commit
11fed7e7f8
2 changed files with 58 additions and 2 deletions
|
@ -47,7 +47,7 @@ import { isConversationUnregistered } from '../../util/isConversationUnregistere
|
|||
import { uuidToBytes } from '../../util/uuidToBytes';
|
||||
import { assertDev, strictAssert } from '../../util/assert';
|
||||
import { getSafeLongFromTimestamp } from '../../util/timestampLongUtils';
|
||||
import { MINUTE, SECOND, DurationInSeconds } from '../../util/durations';
|
||||
import { DAY, MINUTE, SECOND, DurationInSeconds } from '../../util/durations';
|
||||
import {
|
||||
PhoneNumberDiscoverability,
|
||||
parsePhoneNumberDiscoverability,
|
||||
|
@ -111,6 +111,7 @@ import {
|
|||
import type { CoreAttachmentBackupJobType } from '../../types/AttachmentBackup';
|
||||
import { AttachmentBackupManager } from '../../jobs/AttachmentBackupManager';
|
||||
import { getBackupCdnInfo } from './util/mediaId';
|
||||
import { calculateExpirationTimestamp } from '../../util/expirationTimer';
|
||||
import { ReadStatus } from '../../messages/MessageReadStatus';
|
||||
|
||||
const MAX_CONCURRENCY = 10;
|
||||
|
@ -174,7 +175,10 @@ type NonBubbleResultType = Readonly<
|
|||
>;
|
||||
|
||||
export class BackupExportStream extends Readable {
|
||||
private readonly backupTimeMs = getSafeLongFromTimestamp(Date.now());
|
||||
// Shared between all methods for consistency.
|
||||
private now = Date.now();
|
||||
|
||||
private readonly backupTimeMs = getSafeLongFromTimestamp(this.now);
|
||||
private readonly convoIdToRecipientId = new Map<string, number>();
|
||||
private attachmentBackupJobs: Array<CoreAttachmentBackupJobType> = [];
|
||||
private buffers = new Array<Uint8Array>();
|
||||
|
@ -825,6 +829,12 @@ export class BackupExportStream extends Readable {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const expirationTimestamp = calculateExpirationTimestamp(message);
|
||||
if (expirationTimestamp != null && expirationTimestamp <= this.now + DAY) {
|
||||
// Message expires too soon
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let authorId: Long | undefined;
|
||||
|
||||
const isOutgoing = message.type === 'outgoing';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue