From 5ff8a988a8545954bee26fda94021b6a6329ea0c Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 30 May 2022 15:59:26 +0300 Subject: [PATCH] Add config option to disable using restricted join rule --- config/bridge.go | 1 + config/upgrade.go | 1 + example-config.yaml | 3 +++ portal.go | 3 +-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config/bridge.go b/config/bridge.go index f462a12..5fb86cb 100644 --- a/config/bridge.go +++ b/config/bridge.go @@ -32,6 +32,7 @@ type BridgeConfig struct { ChannelnameTemplate string `yaml:"channelname_template"` DeliveryReceipts bool `yaml:"delivery_receipts"` + RestrictedRooms bool `yaml:"restricted_rooms"` CommandPrefix string `yaml:"command_prefix"` diff --git a/config/upgrade.go b/config/upgrade.go index 72cddbd..15378db 100644 --- a/config/upgrade.go +++ b/config/upgrade.go @@ -30,6 +30,7 @@ func DoUpgrade(helper *up.Helper) { helper.Copy(up.Str, "bridge", "channelname_template") helper.Copy(up.Int, "bridge", "portal_message_buffer") helper.Copy(up.Bool, "bridge", "delivery_receipts") + helper.Copy(up.Bool, "bridge", "restricted_rooms") helper.Copy(up.Bool, "bridge", "sync_with_custom_puppets") helper.Copy(up.Bool, "bridge", "sync_direct_chat_list") helper.Copy(up.Bool, "bridge", "federate_rooms") diff --git a/example-config.yaml b/example-config.yaml index 2ad0084..fa95737 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -77,6 +77,9 @@ bridge: # Should the bridge send a read receipt from the bridge bot when a message has been sent to Discord? delivery_receipts: false + # Should the bridge use space-restricted join rules instead of invite-only for guild rooms? + # This can avoid unnecessary invite events in guild rooms when members are synced in. + restricted_rooms: true # Should the bridge sync with double puppeting to receive EDUs that aren't normally sent to appservices. sync_with_custom_puppets: true # Should the bridge update the m.direct account data event when double puppeting is enabled. diff --git a/portal.go b/portal.go index db59b97..7de8496 100644 --- a/portal.go +++ b/portal.go @@ -333,7 +333,7 @@ func (portal *Portal) CreateMatrixRoom(user *User, channel *discordgo.Channel) e }}, }) } - if portal.Guild != nil && portal.Guild.MXID != "" { + if portal.bridge.Config.Bridge.RestrictedRooms && portal.Guild != nil && portal.Guild.MXID != "" { // TODO don't do this for private channels in guilds initialState = append(initialState, &event.Event{ Type: event.StateJoinRules, @@ -346,7 +346,6 @@ func (portal *Portal) CreateMatrixRoom(user *User, channel *discordgo.Channel) e }}, }) } - // TODO set restricted join rule based on guild var invite []id.UserID