1
0
Fork 0

Move Content-Length detection logic

This commit is contained in:
Cadence Ember 2024-01-20 17:25:58 +13:00
parent 845f93e5d0
commit 706b37669b
2 changed files with 8 additions and 6 deletions

View file

@ -48,6 +48,14 @@ async function mreq(method, url, body, extra = {}) {
const root = await res.json()
if (!res.ok || root.errcode) {
if (root.error?.includes("Content-Length")) {
console.error(`OOYE cannot stream uploads to Synapse. Please choose one of these workarounds:`
+ `\n * Run an nginx reverse proxy to Synapse, and point registration.yaml's`
+ `\n \`server_origin\` to nginx`
+ `\n * Set \`content_length_workaround: true\` in registration.yaml (this will`
+ `\n halve the speed of bridging d->m files)`)
throw new Error("Synapse is not accepting stream uploads, see the message above.")
}
delete opts.headers.Authorization
throw new MatrixServerError(root, {baseUrl, url, ...opts})
}

View file

@ -73,12 +73,6 @@ async function uploadAutoEmoji(guild, name, filename) {
} catch (e) {
if (e.errcode === "M_USER_IN_USE" || e.data?.error === "Internal server error") {
// "Internal server error" is the only OK error because older versions of Synapse say this if you try to register the same username twice.
} else if (e.data?.error?.includes("Content-Length")) {
die(`OOYE cannot stream uploads to Synapse. Please choose one of these workarounds:`
+ `\n * Run an nginx reverse proxy to Synapse, and point registration.yaml's`
+ `\n \`server_origin\` to nginx`
+ `\n * Set \`content_length_workaround: true\` in registration.yaml (this will`
+ `\n halve the speed of bridging d->m files)`)
} else {
throw e
}