Move Content-Length detection logic
This commit is contained in:
parent
845f93e5d0
commit
706b37669b
2 changed files with 8 additions and 6 deletions
|
@ -48,6 +48,14 @@ async function mreq(method, url, body, extra = {}) {
|
||||||
const root = await res.json()
|
const root = await res.json()
|
||||||
|
|
||||||
if (!res.ok || root.errcode) {
|
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
|
delete opts.headers.Authorization
|
||||||
throw new MatrixServerError(root, {baseUrl, url, ...opts})
|
throw new MatrixServerError(root, {baseUrl, url, ...opts})
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,12 +73,6 @@ async function uploadAutoEmoji(guild, name, filename) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.errcode === "M_USER_IN_USE" || e.data?.error === "Internal server error") {
|
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.
|
// "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 {
|
} else {
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue