Compare commits

..

2 commits

4 changed files with 16 additions and 13 deletions

View file

@ -61,6 +61,7 @@
}, },
"scripts": { "scripts": {
"start": "node start.js", "start": "node start.js",
"setup": "node scripts/setup.js",
"addbot": "node addbot.js", "addbot": "node addbot.js",
"test": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap test/test.js | tap-dot", "test": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap test/test.js | tap-dot",
"test-slow": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap --no-worker test/test.js -- --slow | tap-dot", "test-slow": "cross-env FORCE_COLOR=true supertape --no-check-assertions-count --format tap --no-worker test/test.js -- --slow | tap-dot",

View file

@ -81,9 +81,9 @@ Follow these steps:
1. Install dependencies: `npm install` 1. Install dependencies: `npm install`
1. Run `node scripts/seed.js` to check your setup and set the bot's initial state. It will prompt you for information. You only need to run this once ever. 1. Run `npm run setup` to check your setup and set the bot's initial state. It will prompt you for information. You only need to run this once ever.
1. Start the bridge: `npm start` 1. Start the bridge: `npm run start`
1. Add the bot to a server - use any *one* of the following commands for an invite link: 1. Add the bot to a server - use any *one* of the following commands for an invite link:
* (in the REPL) `addbot` * (in the REPL) `addbot`
@ -152,8 +152,8 @@ To get into the rooms on your Matrix account, use the `/invite [your mxid here]`
│   └── *.js │   └── *.js
* Various files you can run once if you need them. * Various files you can run once if you need them.
└── scripts └── scripts
* First time running a new bridge? Run this file to plant a seed, which will flourish into state for the bridge: * First time running a new bridge? Run this file to set up prerequisites on the Matrix server:
├── seed.js ├── setup.js
* Hopefully you won't need the rest of these. Code quality varies wildly. * Hopefully you won't need the rest of these. Code quality varies wildly.
└── *.js └── *.js

2
scripts/seed.js → scripts/setup.js Executable file → Normal file
View file

@ -305,7 +305,7 @@ async function validateHomeserverOrigin(serverUrlPrompt, url) {
} }
// Otherwise, it's the user's problem // Otherwise, it's the user's problem
if (!guild) { if (!guild) {
return die(`Error: The bot needs to upload some emojis. Please say where to upload them to. Run seed.js again with --emoji-guild=GUILD_ID`) return die(`Error: The bot needs to upload some emojis. Please say where to upload them to. Run setup again with --emoji-guild=GUILD_ID`)
} }
// Upload those emojis to the chosen location // Upload those emojis to the chosen location
db.prepare("REPLACE INTO auto_emoji (name, emoji_id, guild_id) VALUES ('_', '_', ?)").run(guild.id) db.prepare("REPLACE INTO auto_emoji (name, emoji_id, guild_id) VALUES ('_', '_', ?)").run(guild.id)

View file

@ -5,7 +5,7 @@ const mixin = require("@cloudrac3r/mixin-deep")
const stream = require("stream") const stream = require("stream")
const getStream = require("get-stream") const getStream = require("get-stream")
const {reg} = require("./read-registration.js") const {reg, writeRegistration} = require("./read-registration.js")
const baseUrl = `${reg.ooye.server_origin}/_matrix` const baseUrl = `${reg.ooye.server_origin}/_matrix`
@ -45,13 +45,15 @@ 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")) { if (root.error?.includes("Content-Length") || !reg.ooye.content_length_workaround) {
console.error(`OOYE cannot stream uploads to Synapse. Please choose one of these workarounds:` reg.ooye.content_length_workaround = true
+ `\n * Run an nginx reverse proxy to Synapse, and point registration.yaml's` const root = await mreq(method, url, body, extra)
+ `\n \`server_origin\` to nginx` console.error("OOYE cannot stream uploads to Synapse. The `content_length_workaround` option"
+ `\n * Set \`content_length_workaround: true\` in registration.yaml (this will` + "\nhas been activated in registration.yaml, which works around the problem, but"
+ `\n halve the speed of bridging d->m files)`) + "\nhalves the speed of bridging d->m files. A better way to resolve this problem"
throw new Error("Synapse is not accepting stream uploads, see the message above.") + "\nis to run an nginx reverse proxy to Synapse and re-run OOYE setup.")
writeRegistration(reg)
return root
} }
delete opts.headers.Authorization delete opts.headers.Authorization
throw new MatrixServerError(root, {baseUrl, url, ...opts}) throw new MatrixServerError(root, {baseUrl, url, ...opts})