Drop group messages that don't change group

This commit is contained in:
Josh Perez 2020-07-06 20:39:55 -04:00 committed by Scott Nonnenberg
parent 4289c28a38
commit ba6cb653bf
7 changed files with 158 additions and 117 deletions

View 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;
}

View file

@ -4,6 +4,7 @@ import { arrayBufferToObjectURL } from './arrayBufferToObjectURL';
import { combineNames } from './combineNames';
import { createBatcher } from './batcher';
import { createWaitBatcher } from './waitBatcher';
import { downloadAttachment } from './downloadAttachment';
import { hasExpired } from './hasExpired';
import { isFileDangerous } from './isFileDangerous';
import { makeLookup } from './makeLookup';
@ -16,6 +17,7 @@ export {
combineNames,
createBatcher,
createWaitBatcher,
downloadAttachment,
GoogleChrome,
hasExpired,
isFileDangerous,