forked from cadence/out-of-your-element
Compare commits
No commits in common. "a66b93ed2625dacf7cb5f24191c1baa2f8f7fdf2" and "5a853249a295ecc2e6a0ce9a7f0df87811872bc1" have entirely different histories.
a66b93ed26
...
5a853249a2
2 changed files with 3 additions and 13 deletions
|
|
@ -39,20 +39,14 @@ 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"))
|
||||
await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(
|
||||
// @ts-ignore
|
||||
res.body
|
||||
).pipe(d))
|
||||
await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(res.body).pipe(d))
|
||||
return {
|
||||
name: p.name,
|
||||
file: d
|
||||
}
|
||||
} else {
|
||||
// Unencrypted file
|
||||
const body = await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(
|
||||
// @ts-ignore
|
||||
res.body
|
||||
))
|
||||
const body = await api.getMedia(p.mxc).then(res => stream.Readable.fromWeb(res.body))
|
||||
return {
|
||||
name: p.name,
|
||||
file: body
|
||||
|
|
|
|||
|
|
@ -156,12 +156,8 @@ async function sendError(roomID, source, type, e, payload) {
|
|||
} catch (e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {(event: any, ...args: any)=>any} fn
|
||||
*/
|
||||
function guard(type, fn) {
|
||||
return async function(/** @type {Ty.Event.Outer<any>} */ event, /** @type {any} */ ...args) {
|
||||
return async function(event, ...args) {
|
||||
try {
|
||||
return await fn(event, ...args)
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue