Resumable attachment downloads

This commit is contained in:
Fedor Indutny 2024-08-19 13:05:35 -07:00 committed by GitHub
parent 2c92591b59
commit 38f532cdda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 401 additions and 89 deletions

View file

@ -32,6 +32,7 @@ import { filterAndClean } from '../types/BodyRange';
import { isAciString } from '../util/isAciString';
import { normalizeAci } from '../util/normalizeAci';
import { bytesToUuid } from '../util/uuidToBytes';
import { createName } from '../util/attachmentPath';
const FLAGS = Proto.DataMessage.Flags;
export const ATTACHMENT_MAX = 32;
@ -284,7 +285,10 @@ export function processGiftBadge(
export function processDataMessage(
message: Proto.IDataMessage,
envelopeTimestamp: number
envelopeTimestamp: number,
// Only for testing
{ _createName: doCreateName = createName } = {}
): ProcessedDataMessage {
/* eslint-disable no-bitwise */
@ -309,7 +313,10 @@ export function processDataMessage(
const result: ProcessedDataMessage = {
body: dropNull(message.body),
attachments: (message.attachments ?? []).map(
(attachment: Proto.IAttachmentPointer) => processAttachment(attachment)
(attachment: Proto.IAttachmentPointer) => ({
...processAttachment(attachment),
downloadPath: doCreateName(),
})
),
groupV2: processGroupV2Context(message.groupV2),
flags: message.flags ?? 0,