浏览代码

Add config option to disable using restricted join rule

Tulir Asokan 3 年之前
父节点
当前提交
5ff8a988a8
共有 4 个文件被更改,包括 6 次插入2 次删除
  1. 1 0
      config/bridge.go
  2. 1 0
      config/upgrade.go
  3. 3 0
      example-config.yaml
  4. 1 2
      portal.go

+ 1 - 0
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"`
 

+ 1 - 0
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")

+ 3 - 0
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.

+ 1 - 2
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