Add config option to disable using restricted join rule

This commit is contained in:
Tulir Asokan
2022-05-30 15:59:26 +03:00
parent aa666c9889
commit 5ff8a988a8
4 changed files with 6 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ type BridgeConfig struct {
ChannelnameTemplate string `yaml:"channelname_template"` ChannelnameTemplate string `yaml:"channelname_template"`
DeliveryReceipts bool `yaml:"delivery_receipts"` DeliveryReceipts bool `yaml:"delivery_receipts"`
RestrictedRooms bool `yaml:"restricted_rooms"`
CommandPrefix string `yaml:"command_prefix"` CommandPrefix string `yaml:"command_prefix"`

View File

@@ -30,6 +30,7 @@ func DoUpgrade(helper *up.Helper) {
helper.Copy(up.Str, "bridge", "channelname_template") helper.Copy(up.Str, "bridge", "channelname_template")
helper.Copy(up.Int, "bridge", "portal_message_buffer") helper.Copy(up.Int, "bridge", "portal_message_buffer")
helper.Copy(up.Bool, "bridge", "delivery_receipts") 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_with_custom_puppets")
helper.Copy(up.Bool, "bridge", "sync_direct_chat_list") helper.Copy(up.Bool, "bridge", "sync_direct_chat_list")
helper.Copy(up.Bool, "bridge", "federate_rooms") helper.Copy(up.Bool, "bridge", "federate_rooms")

View File

@@ -77,6 +77,9 @@ bridge:
# Should the bridge send a read receipt from the bridge bot when a message has been sent to Discord? # Should the bridge send a read receipt from the bridge bot when a message has been sent to Discord?
delivery_receipts: false 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. # Should the bridge sync with double puppeting to receive EDUs that aren't normally sent to appservices.
sync_with_custom_puppets: true sync_with_custom_puppets: true
# Should the bridge update the m.direct account data event when double puppeting is enabled. # Should the bridge update the m.direct account data event when double puppeting is enabled.

View File

@@ -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 // TODO don't do this for private channels in guilds
initialState = append(initialState, &event.Event{ initialState = append(initialState, &event.Event{
Type: event.StateJoinRules, 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 var invite []id.UserID