Still reviewing.. but here are some comments that would be helpful to have answered.
376 | let exclusionQuerys = []; | ||
377 | console.log(server.getNetworkId(), server.getAutoCreateMappings()); | ||
378 | for (const mapping of server.getAutoCreateMappings()) { | ||
379 | exclusionQuerys.push(mapping.channel); |
Even though this comes from a config that only an admin can configure, I wish we would escape the channel names before putting them into an SQL statement.
15 | createRoom: true, | ||
16 | }; | ||
17 | |||
18 | await test.beforeEach(env); |
What is this?
... Looks up env-bundle...
68 | for (const [channel, data] of Object.entries(serverConfig.mappings)) { | ||
69 | if (data.createRoom) { | ||
70 | // We don't want to map this. | ||
71 | return; |
Return, not continue??
I have a habit of mixing those up 😆
.map and functions let you use your preferred return command. 😀
return; | |
continue; |
95 | |||
96 | for (const [channel, opts] of Object.entries(serverConfig.mappings)) { | ||
97 | if (opts.createRoom) { | ||
98 | return; |
One opts.createRoom makes the entire setting of the server impossible?
422 | 429 | }); | |
430 | const notChannels = server.getAutoCreateMappings().map((c) => c.channel); | ||
431 | entries = (await entries).filter((e) => e.remote?.get("domain") === server.domain && | ||
432 | !notChannels.includes(e.remote?.get("channel") as string)); |
remote?
but a cast to string.
That seems like a cast where we're possibly lying to get TypeScript happy. Can this not be string or undefined?
428 | origin: 'config', | ||
422 | 429 | }); | |
430 | const notChannels = server.getAutoCreateMappings().map((c) => c.channel); | ||
431 | entries = (await entries).filter((e) => e.remote?.get("domain") === server.domain && |
entries was already awaited two lines above.
Login to write a write a comment.
Fixes #1096
The idea behind this is that you can just specify a bunch of mappings in your config and have rooms be created on the fly for them.
There are a few problems though. The behavior of
mappings
is to normally only bridge things defined in the section. If you remove a mapping entry, the bridge should stop bridging it. However this is more difficult in this case as the roomId is created by the bridge and not stored in the config. We need to persist it in the db, but this means adding special behaviors. I've done this for postgres, but it's harder to do in NeDB.