Fix m->d encrypted files

This commit is contained in:
Cadence Ember 2025-02-16 17:15:01 +13:00
commit a05868f418
3 changed files with 10 additions and 7 deletions

View file

@ -37,16 +37,15 @@ async function resolvePendingFiles(message) {
if ("key" in p) {
// Encrypted file
const d = crypto.createDecipheriv("aes-256-ctr", Buffer.from(p.key, "base64url"), Buffer.from(p.iv, "base64url"))
// @ts-ignore
await api.getMedia(p.mxc).then(res => res.body.pipe(d))
await api.getMedia(p.mxc).then(res => Readable.fromWeb(res.body).pipe(d))
return {
name: p.name,
file: d
}
} else {
// Unencrypted file
/** @type {Readable} */ // @ts-ignore
const body = await api.getMedia(p.mxc).then(res => res.body)
/** @type {Readable} */
const body = await api.getMedia(p.mxc).then(res => Readable.fromWeb(res.body))
return {
name: p.name,
file: body