forked from cadence/out-of-your-element
Compare commits
2 commits
5a853249a2
...
a66b93ed26
| Author | SHA1 | Date | |
|---|---|---|---|
| a66b93ed26 | |||
| 2c7831c587 |
2 changed files with 13 additions and 3 deletions
|
|
@ -39,14 +39,20 @@ async function resolvePendingFiles(message) {
|
||||||
if ("key" in p) {
|
if ("key" in p) {
|
||||||
// Encrypted file
|
// Encrypted file
|
||||||
const d = crypto.createDecipheriv("aes-256-ctr", Buffer.from(p.key, "base64url"), Buffer.from(p.iv, "base64url"))
|
const d = crypto.createDecipheriv("aes-256-ctr", Buffer.from(p.key, "base64url"), Buffer.from(p.iv, "base64url"))
|
||||||
await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(res.body).pipe(d))
|
await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(
|
||||||
|
// @ts-ignore
|
||||||
|
res.body
|
||||||
|
).pipe(d))
|
||||||
return {
|
return {
|
||||||
name: p.name,
|
name: p.name,
|
||||||
file: d
|
file: d
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unencrypted file
|
// Unencrypted file
|
||||||
const body = await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(res.body))
|
const body = await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(
|
||||||
|
// @ts-ignore
|
||||||
|
res.body
|
||||||
|
))
|
||||||
return {
|
return {
|
||||||
name: p.name,
|
name: p.name,
|
||||||
file: body
|
file: body
|
||||||
|
|
|
||||||
|
|
@ -156,8 +156,12 @@ async function sendError(roomID, source, type, e, payload) {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} type
|
||||||
|
* @param {(event: any, ...args: any)=>any} fn
|
||||||
|
*/
|
||||||
function guard(type, fn) {
|
function guard(type, fn) {
|
||||||
return async function(event, ...args) {
|
return async function(/** @type {Ty.Event.Outer<any>} */ event, /** @type {any} */ ...args) {
|
||||||
try {
|
try {
|
||||||
return await fn(event, ...args)
|
return await fn(event, ...args)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue