More protobufjs migration
This commit is contained in:
parent
cf06e6638e
commit
ddbbe3a6b1
70 changed files with 3967 additions and 3369 deletions
|
@ -1,26 +1,29 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import {
|
||||
AttachmentPointerClass,
|
||||
DownloadAttachmentType,
|
||||
} from '../textsecure.d';
|
||||
import { DownloadAttachmentType } from '../textsecure.d';
|
||||
|
||||
type AttachmentData = AttachmentPointerClass & {
|
||||
id?: string;
|
||||
};
|
||||
import { AttachmentType } from '../types/Attachment';
|
||||
|
||||
export async function downloadAttachment(
|
||||
attachmentData: AttachmentData
|
||||
attachmentData: AttachmentType
|
||||
): Promise<DownloadAttachmentType | null> {
|
||||
let migratedAttachment: AttachmentType;
|
||||
|
||||
const { id: legacyId } = attachmentData;
|
||||
if (legacyId === undefined) {
|
||||
migratedAttachment = attachmentData;
|
||||
} else {
|
||||
migratedAttachment = {
|
||||
...attachmentData,
|
||||
cdnId: String(legacyId),
|
||||
};
|
||||
}
|
||||
|
||||
let downloaded;
|
||||
try {
|
||||
if (attachmentData.id) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
attachmentData.cdnId = attachmentData.id;
|
||||
}
|
||||
downloaded = await window.textsecure.messageReceiver.downloadAttachment(
|
||||
attachmentData
|
||||
migratedAttachment
|
||||
);
|
||||
} catch (error) {
|
||||
// Attachments on the server expire after 30 days, then start returning 404
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue