From a1710af542cfbd75748304c006d41a30c6b461fe Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 13 Oct 2023 00:39:45 +1300 Subject: [PATCH 1/2] Explain that auto-invite also marks as admin --- registration.example.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/registration.example.yaml b/registration.example.yaml index bad42fe..9e7cd2c 100644 --- a/registration.example.yaml +++ b/registration.example.yaml @@ -19,4 +19,5 @@ ooye: server_name: [the part after the colon in your matrix id, like cadence.moe] server_origin: [the full protocol and domain of your actual matrix server's location, with no trailing slash, like https://matrix.cadence.moe] invite: - # - @cadence:cadence.moe # uncomment this to auto-invite the named user to newly created spaces + # uncomment this to auto-invite the named user to newly created spaces and mark them as admin (PL 100) everywhere + # - @cadence:cadence.moe From 1ad1c6b525c924d29b1e17e638547601427b4322 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Fri, 13 Oct 2023 00:51:38 +1300 Subject: [PATCH 2/2] Add tests for all room privacy levels --- d2m/actions/create-room.test.js | 29 ++++++++++++++++++++++++++++- test/data.js | 3 +++ test/test.js | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/d2m/actions/create-room.test.js b/d2m/actions/create-room.test.js index e40bf6f..93f9203 100644 --- a/d2m/actions/create-room.test.js +++ b/d2m/actions/create-room.test.js @@ -5,7 +5,34 @@ const {kstateStripConditionals} = require("../../matrix/kstate") const {test} = require("supertape") const testData = require("../../test/data") -test("channel2room: general", async t => { +const passthrough = require("../../passthrough") +const {db} = passthrough + +test("channel2room: discoverable privacy room", async t => { + db.prepare("UPDATE guild_space SET privacy_level = 2").run() + t.deepEqual( + kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)), + Object.assign({}, testData.room.general, { + "m.room.guest_access/": {guest_access: "forbidden"}, + "m.room.join_rules/": {join_rule: "public"}, + "m.room.history_visibility/": {history_visibility: "world_readable"} + }) + ) +}) + +test("channel2room: linkable privacy room", async t => { + db.prepare("UPDATE guild_space SET privacy_level = 1").run() + t.deepEqual( + kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)), + Object.assign({}, testData.room.general, { + "m.room.guest_access/": {guest_access: "forbidden"}, + "m.room.join_rules/": {join_rule: "public"} + }) + ) +}) + +test("channel2room: invite-only privacy room", async t => { + db.prepare("UPDATE guild_space SET privacy_level = 0").run() t.deepEqual( kstateStripConditionals(await channelToKState(testData.channel.general, testData.guild.general).then(x => x.channelKState)), testData.room.general diff --git a/test/data.js b/test/data.js index 4919beb..c5a1f8e 100644 --- a/test/data.js +++ b/test/data.js @@ -44,6 +44,9 @@ module.exports = { "m.room.power_levels/": { events: { "m.room.avatar": 0 + }, + users: { + "@test_auto_invite:example.org": 100 } }, "chat.schildi.hide_ui/read_receipts": {hidden: true}, diff --git a/test/test.js b/test/test.js index 280503d..5e15a14 100644 --- a/test/test.js +++ b/test/test.js @@ -14,6 +14,7 @@ const db = new sqlite(":memory:") const reg = require("../matrix/read-registration") reg.ooye.server_origin = "https://matrix.cadence.moe" // so that tests will pass even when hard-coded +reg.ooye.invite = ["@test_auto_invite:example.org"] const sync = new HeatSync({watchFS: false})