Преглед на файлове

Add option to allow inviting other users in portal rooms (#77)

This doesn't mean the invited users get bridged, but for some use cases that doesn't matter
progserega преди 6 години
родител
ревизия
92958343dd
променени са 3 файла, в които са добавени 11 реда и са изтрити 1 реда
  1. 2 0
      config/bridge.go
  2. 4 0
      example-config.yaml
  3. 5 1
      portal.go

+ 2 - 0
config/bridge.go

@@ -50,6 +50,8 @@ type BridgeConfig struct {
 	InviteOwnPuppetForBackfilling bool `yaml:"invite_own_puppet_for_backfilling"`
 	PrivateChatPortalMeta         bool `yaml:"private_chat_portal_meta"`
 
+	AllowUserInvite         bool `yaml:"allow_user_invite"`
+
 	CommandPrefix string `yaml:"command_prefix"`
 
 	Permissions PermissionConfig `yaml:"permissions"`

+ 4 - 0
example-config.yaml

@@ -101,6 +101,10 @@ bridge:
     # but causes room avatar/name bugs.
     private_chat_portal_meta: false
 
+    # Allow invite permission for user. User can invite any bots to room with whatsapp 
+    # users (private chat and groups)
+    allow_user_invite: false
+
     # The prefix for commands. Only required in non-management rooms.
     command_prefix: "!wa"
 

+ 5 - 1
portal.go

@@ -460,13 +460,17 @@ func (portal *Portal) Sync(user *User, contact whatsapp.Contact) {
 func (portal *Portal) GetBasePowerLevels() *mautrix.PowerLevels {
 	anyone := 0
 	nope := 99
+	invite := 99
+	if portal.bridge.Config.Bridge.AllowUserInvite {
+		invite = 0
+	}
 	return &mautrix.PowerLevels{
 		UsersDefault:    anyone,
 		EventsDefault:   anyone,
 		RedactPtr:       &anyone,
 		StateDefaultPtr: &nope,
 		BanPtr:          &nope,
-		InvitePtr:       &nope,
+		InvitePtr:       &invite,
 		Users: map[string]int{
 			portal.MainIntent().UserID: 100,
 		},