Add downloadPath to attachments after import to support resumable download
This commit is contained in:
parent
01581b04d8
commit
34ab08aeeb
3 changed files with 52 additions and 6 deletions
|
@ -4,7 +4,7 @@
|
|||
import { assert } from 'chai';
|
||||
import path from 'path';
|
||||
import { tmpdir } from 'os';
|
||||
import { sortBy } from 'lodash';
|
||||
import { omit, sortBy } from 'lodash';
|
||||
import { createReadStream } from 'fs';
|
||||
import { mkdtemp, rm } from 'fs/promises';
|
||||
import * as sinon from 'sinon';
|
||||
|
@ -65,6 +65,11 @@ function sortAndNormalize(
|
|||
reactions,
|
||||
sendStateByConversationId,
|
||||
verifiedChanged,
|
||||
attachments,
|
||||
preview,
|
||||
contact,
|
||||
quote,
|
||||
sticker,
|
||||
|
||||
// This is not in the backup
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
@ -122,6 +127,36 @@ function sortAndNormalize(
|
|||
};
|
||||
}),
|
||||
|
||||
attachments: attachments?.map(attachment =>
|
||||
omit(attachment, 'downloadPath')
|
||||
),
|
||||
preview: preview?.map(previewItem => ({
|
||||
...previewItem,
|
||||
image: omit(previewItem.image, 'downloadPath'),
|
||||
})),
|
||||
contact: contact?.map(contactItem => ({
|
||||
...contactItem,
|
||||
avatar: {
|
||||
...contactItem.avatar,
|
||||
avatar: omit(contactItem.avatar?.avatar, 'downloadPath'),
|
||||
},
|
||||
})),
|
||||
quote: quote
|
||||
? {
|
||||
...quote,
|
||||
attachments: quote?.attachments.map(quotedAttachment => ({
|
||||
...quotedAttachment,
|
||||
thumbnail: omit(quotedAttachment.thumbnail, 'downloadPath'),
|
||||
})),
|
||||
}
|
||||
: undefined,
|
||||
sticker: sticker
|
||||
? {
|
||||
...sticker,
|
||||
data: omit(sticker.data, 'downloadPath'),
|
||||
}
|
||||
: undefined,
|
||||
|
||||
// Not an original property, but useful
|
||||
isUnsupported: isUnsupportedMessage(message),
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue