Continue toasting for recently received attachments that are missing from backup tier

This commit is contained in:
trevor-signal
2025-12-17 10:47:01 -05:00
committed by GitHub
parent c9457f31db
commit 07f14f3ed0
3 changed files with 10 additions and 25 deletions

View File

@@ -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<DependenciesType, 'runDownloadAttachmentJobInner'>;
messageExpiresAt: number | null;
messageReceivedAtMs: number | null;
} & RunDownloadAttachmentJobOptions): Promise<DownloadAttachmentResultType> {
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,
},

View File

@@ -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,

View File

@@ -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,