Drop group messages that don't change group
This commit is contained in:
parent
4289c28a38
commit
ba6cb653bf
7 changed files with 158 additions and 117 deletions
32
ts/util/downloadAttachment.ts
Normal file
32
ts/util/downloadAttachment.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import {
|
||||
AttachmentPointerClass,
|
||||
DownloadAttachmentType,
|
||||
} from '../textsecure.d';
|
||||
|
||||
type AttachmentData = AttachmentPointerClass & {
|
||||
id?: string;
|
||||
};
|
||||
|
||||
export async function downloadAttachment(
|
||||
attachmentData: AttachmentData
|
||||
): Promise<DownloadAttachmentType | null> {
|
||||
let downloaded;
|
||||
try {
|
||||
if (attachmentData.id) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
attachmentData.cdnId = attachmentData.id;
|
||||
}
|
||||
downloaded = await window.textsecure.messageReceiver.downloadAttachment(
|
||||
attachmentData
|
||||
);
|
||||
} catch (error) {
|
||||
// Attachments on the server expire after 30 days, then start returning 404
|
||||
if (error && error.code === 404) {
|
||||
return null;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
return downloaded;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue