forked from cadence/out-of-your-element
only include necessary data for testing
This commit is contained in:
parent
e08262388b
commit
36adc30990
4 changed files with 114 additions and 9 deletions
|
@ -40,15 +40,8 @@ async function uploadDiscordFileToMxc(path) {
|
|||
|
||||
// Download from Discord
|
||||
const promise = fetch(url, {}).then(/** @param {import("node-fetch").Response} res */ async res => {
|
||||
const body = res.body
|
||||
|
||||
// Upload to Matrix
|
||||
/** @type {import("../types").R.FileUploaded} */
|
||||
const root = await mreq.mreq("POST", "/media/v3/upload", body, {
|
||||
headers: {
|
||||
"Content-Type": res.headers.get("content-type")
|
||||
}
|
||||
})
|
||||
const root = await module.exports._actuallyUploadDiscordFileToMxc(url, res)
|
||||
|
||||
// Store relationship in database
|
||||
db.prepare("INSERT INTO file (discord_url, mxc_url) VALUES (?, ?)").run(url, root.content_uri)
|
||||
|
@ -61,6 +54,17 @@ async function uploadDiscordFileToMxc(path) {
|
|||
return promise
|
||||
}
|
||||
|
||||
async function _actuallyUploadDiscordFileToMxc(url, res) {
|
||||
const body = res.body
|
||||
/** @type {import("../types").R.FileUploaded} */
|
||||
const root = await mreq.mreq("POST", "/media/v3/upload", body, {
|
||||
headers: {
|
||||
"Content-Type": res.headers.get("content-type")
|
||||
}
|
||||
})
|
||||
return root
|
||||
}
|
||||
|
||||
function guildIcon(guild) {
|
||||
return `/icons/${guild.id}/${guild.icon}.png?size=${IMAGE_SIZE}`
|
||||
}
|
||||
|
@ -102,3 +106,4 @@ module.exports.emoji = emoji
|
|||
module.exports.stickerFormat = stickerFormat
|
||||
module.exports.sticker = sticker
|
||||
module.exports.uploadDiscordFileToMxc = uploadDiscordFileToMxc
|
||||
module.exports._actuallyUploadDiscordFileToMxc = _actuallyUploadDiscordFileToMxc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue