From 07f14f3ed09b0f6316a5edb984ac2bebfc33b819 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Wed, 17 Dec 2025 10:47:01 -0500 Subject: [PATCH] Continue toasting for recently received attachments that are missing from backup tier --- ts/jobs/AttachmentDownloadManager.preload.ts | 9 +++++---- .../AttachmentDownloadManager_test.preload.ts | 7 ------- ts/util/downloadAttachment.preload.ts | 19 +++++-------------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/ts/jobs/AttachmentDownloadManager.preload.ts b/ts/jobs/AttachmentDownloadManager.preload.ts index 6eb33c56a8..712a90fa78 100644 --- a/ts/jobs/AttachmentDownloadManager.preload.ts +++ b/ts/jobs/AttachmentDownloadManager.preload.ts @@ -544,7 +544,6 @@ export async function runDownloadAttachmentJob({ dependencies, messageExpiresAt: calculateExpirationTimestamp(message.attributes) ?? null, - messageReceivedAtMs: message.attributes.received_at_ms ?? null, }); if (result.downloadedVariant === AttachmentVariant.ThumbnailFromBackup) { @@ -719,13 +718,11 @@ export async function runDownloadAttachmentJobInner({ maxTextAttachmentSizeInKib, hasMediaBackups, messageExpiresAt, - messageReceivedAtMs, dependencies, }: { job: AttachmentDownloadJobType; dependencies: Omit; messageExpiresAt: number | null; - messageReceivedAtMs: number | null; } & RunDownloadAttachmentJobOptions): Promise { const { messageId, attachment, attachmentType } = job; @@ -786,6 +783,7 @@ export async function runDownloadAttachmentJobInner({ abortSignal, dependencies, logId, + messageExpiresAt, }); await addAttachmentToMessage( messageId, @@ -855,7 +853,6 @@ export async function runDownloadAttachmentJobInner({ abortSignal, hasMediaBackups, logId, - messageReceivedAtMs, messageExpiresAt, }, }); @@ -934,6 +931,7 @@ export async function runDownloadAttachmentJobInner({ abortSignal, dependencies, logId, + messageExpiresAt, }); await addAttachmentToMessage( @@ -991,10 +989,12 @@ async function downloadBackupThumbnail({ abortSignal, logId, dependencies, + messageExpiresAt, }: { attachment: AttachmentType; abortSignal: AbortSignal; logId: string; + messageExpiresAt: number | null; dependencies: { downloadAttachment: typeof downloadAttachmentUtil; }; @@ -1005,6 +1005,7 @@ async function downloadBackupThumbnail({ onSizeUpdate: noop, variant: AttachmentVariant.ThumbnailFromBackup, abortSignal, + messageExpiresAt, hasMediaBackups: true, logId, }, diff --git a/ts/test-electron/services/AttachmentDownloadManager_test.preload.ts b/ts/test-electron/services/AttachmentDownloadManager_test.preload.ts index c30c6deaaa..2ea0a3f2a8 100644 --- a/ts/test-electron/services/AttachmentDownloadManager_test.preload.ts +++ b/ts/test-electron/services/AttachmentDownloadManager_test.preload.ts @@ -908,7 +908,6 @@ describe('AttachmentDownloadManager.runDownloadAttachmentJobInner', () => { maxAttachmentSizeInKib: 100 * MEBIBYTE, maxTextAttachmentSizeInKib: 2 * MEBIBYTE, messageExpiresAt: null, - messageReceivedAtMs: null, dependencies: { deleteAttachmentData, deleteDownloadData, @@ -949,7 +948,6 @@ describe('AttachmentDownloadManager.runDownloadAttachmentJobInner', () => { maxAttachmentSizeInKib: 100 * MEBIBYTE, maxTextAttachmentSizeInKib: 2 * MEBIBYTE, messageExpiresAt: null, - messageReceivedAtMs: null, dependencies: { deleteAttachmentData, deleteDownloadData, @@ -1007,7 +1005,6 @@ describe('AttachmentDownloadManager.runDownloadAttachmentJobInner', () => { maxAttachmentSizeInKib: 100 * MEBIBYTE, maxTextAttachmentSizeInKib: 2 * MEBIBYTE, messageExpiresAt: null, - messageReceivedAtMs: null, dependencies: { deleteAttachmentData, deleteDownloadData, @@ -1047,7 +1044,6 @@ describe('AttachmentDownloadManager.runDownloadAttachmentJobInner', () => { maxAttachmentSizeInKib: 100 * MEBIBYTE, maxTextAttachmentSizeInKib: 2 * MEBIBYTE, messageExpiresAt: null, - messageReceivedAtMs: null, dependencies: { deleteAttachmentData, deleteDownloadData, @@ -1088,7 +1084,6 @@ describe('AttachmentDownloadManager.runDownloadAttachmentJobInner', () => { maxAttachmentSizeInKib: 100 * MEBIBYTE, maxTextAttachmentSizeInKib: 2 * MEBIBYTE, messageExpiresAt: null, - messageReceivedAtMs: null, dependencies: { deleteAttachmentData, deleteDownloadData, @@ -1127,7 +1122,6 @@ describe('AttachmentDownloadManager.runDownloadAttachmentJobInner', () => { maxAttachmentSizeInKib: 100 * MEBIBYTE, maxTextAttachmentSizeInKib: 2 * MEBIBYTE, messageExpiresAt: null, - messageReceivedAtMs: null, dependencies: { deleteAttachmentData, deleteDownloadData, @@ -1185,7 +1179,6 @@ describe('AttachmentDownloadManager.runDownloadAttachmentJobInner', () => { maxAttachmentSizeInKib: 100 * MEBIBYTE, maxTextAttachmentSizeInKib: 2 * MEBIBYTE, messageExpiresAt: null, - messageReceivedAtMs: null, dependencies: { deleteAttachmentData, deleteDownloadData, diff --git a/ts/util/downloadAttachment.preload.ts b/ts/util/downloadAttachment.preload.ts index 27b55930fd..228f015420 100644 --- a/ts/util/downloadAttachment.preload.ts +++ b/ts/util/downloadAttachment.preload.ts @@ -26,8 +26,6 @@ import * as RemoteConfig from '../RemoteConfig.dom.js'; import { ToastType } from '../types/Toast.dom.js'; import { isAbortError } from './isAbortError.std.js'; import { expiresTooSoonForBackup } from '../services/backups/util/expiration.std.js'; -import { isMoreRecentThan } from './timestamp.std.js'; -import { DAY } from './durations/constants.std.js'; const log = createLogger('downloadAttachment'); @@ -39,7 +37,6 @@ export async function downloadAttachment({ abortSignal, hasMediaBackups, logId: _logId, - messageReceivedAtMs, messageExpiresAt, }, dependencies = { @@ -54,8 +51,7 @@ export async function downloadAttachment({ abortSignal: AbortSignal; hasMediaBackups: boolean; logId: string; - messageExpiresAt?: number | null; - messageReceivedAtMs?: number | null; + messageExpiresAt: number | null; }; dependencies?: { downloadAttachmentFromServer: typeof doDownloadAttachment; @@ -69,15 +65,11 @@ export async function downloadAttachment({ const isBackupable = hasRequiredInformationForRemoteBackup(attachment); const mightBeOnBackupTierNow = isBackupable && hasMediaBackups; - const mightBeExpiredFromBackupTier = - messageExpiresAt != null && - expiresTooSoonForBackup({ - messageExpiresAt, - }); + const mightBeExpiredFromBackupTier = expiresTooSoonForBackup({ + messageExpiresAt, + }); const mightBeOnBackupTierInTheFuture = isBackupable && !mightBeExpiredFromBackupTier; - const mightNotYetBeBackedUp = - messageReceivedAtMs && isMoreRecentThan(messageReceivedAtMs, DAY); if (wasImportedFromLocalBackup(attachment)) { log.info(`${logId}: Downloading attachment from local backup`); @@ -130,8 +122,7 @@ export async function downloadAttachment({ if ( RemoteConfig.isEnabled('desktop.internalUser') && - !mightBeExpiredFromBackupTier && - !mightNotYetBeBackedUp + !mightBeExpiredFromBackupTier ) { window.reduxActions.toast.showToast({ toastType: ToastType.UnableToDownloadFromBackupTier,