Enable more specific AttachmentDownload prioritization
This commit is contained in:
parent
87ea909ae9
commit
fc02762588
26 changed files with 2245 additions and 817 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue