Enable more specific AttachmentDownload prioritization

This commit is contained in:
trevor-signal 2024-04-15 20:11:48 -04:00 committed by GitHub
parent 87ea909ae9
commit fc02762588
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 2245 additions and 817 deletions

View file

@ -4,9 +4,10 @@
import type { AttachmentType } from '../types/Attachment';
import { downloadAttachmentV2 as doDownloadAttachment } from '../textsecure/downloadAttachment';
export class AttachmentNotFoundOnCdnError extends Error {}
export async function downloadAttachment(
attachmentData: AttachmentType
): Promise<AttachmentType | null> {
): Promise<AttachmentType> {
let migratedAttachment: AttachmentType;
const { server } = window.textsecure;
@ -30,7 +31,7 @@ export async function downloadAttachment(
} catch (error) {
// Attachments on the server expire after 30 days, then start returning 404 or 403
if (error && (error.code === 404 || error.code === 403)) {
return null;
throw new AttachmentNotFoundOnCdnError(error.code);
}
throw error;