1
0
Fork 0

fix join rules on old room versions

This commit is contained in:
Cadence Ember 2023-09-04 01:36:58 +12:00
parent d3f637d7ce
commit d255f2ab22

View file

@ -95,6 +95,7 @@ async function channelToKState(channel, guild) {
via: [reg.ooye.server_name], via: [reg.ooye.server_name],
canonical: true canonical: true
}, },
/** @type {{join_rule: string, [x: string]: any}} */
"m.room.join_rules/": { "m.room.join_rules/": {
join_rule: "restricted", join_rule: "restricted",
allow: [{ allow: [{
@ -255,6 +256,12 @@ async function _syncRoom(channelID, shouldActuallySync) {
// sync channel state to room // sync channel state to room
const roomKState = await roomToKState(roomID) const roomKState = await roomToKState(roomID)
if (+roomKState["m.room.create/"].room_version <= 8) {
// join_rule `restricted` is not available in room version < 8 and not working properly in version == 8
// read more: https://spec.matrix.org/v1.8/rooms/v9/
// we have to use `public` instead, otherwise the room will be unjoinable.
channelKState["m.room.join_rules/"] = {join_rule: "public"}
}
const roomDiff = ks.diffKState(roomKState, channelKState) const roomDiff = ks.diffKState(roomKState, channelKState)
const roomApply = applyKStateDiffToRoom(roomID, roomDiff) const roomApply = applyKStateDiffToRoom(roomID, roomDiff)
db.prepare("UPDATE channel_room SET name = ? WHERE room_id = ?").run(channel.name, roomID) db.prepare("UPDATE channel_room SET name = ? WHERE room_id = ?").run(channel.name, roomID)