From 92958343ddc30b5dfd4205ef6cd2817b226054b5 Mon Sep 17 00:00:00 2001 From: progserega Date: Tue, 16 Jul 2019 19:16:17 +1000 Subject: [PATCH] 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 --- config/bridge.go | 2 ++ example-config.yaml | 4 ++++ portal.go | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/bridge.go b/config/bridge.go index 5468d19..d263333 100644 --- a/config/bridge.go +++ b/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"` diff --git a/example-config.yaml b/example-config.yaml index 5facea5..3947b00 100644 --- a/example-config.yaml +++ b/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" diff --git a/portal.go b/portal.go index 5351429..9c559c1 100644 --- a/portal.go +++ b/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, },