Changeset

4766:abac64f71698

mod_invites_adhoc: Add the ability to deny user invites by specific roles
author Matthew Wild <mwild1@gmail.com>
date Tue, 09 Nov 2021 11:33:06 +0000
parents 4765:3632836f35b0
children 4767:ea93b204104e
files mod_invites_adhoc/mod_invites_adhoc.lua
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_invites_adhoc/mod_invites_adhoc.lua	Mon Nov 08 23:07:01 2021 +0100
+++ b/mod_invites_adhoc/mod_invites_adhoc.lua	Tue Nov 09 11:33:06 2021 +0000
@@ -14,6 +14,7 @@
 local allow_contact_invites = module:get_option_boolean("allow_contact_invites", true);
 
 local allow_user_invite_roles = module:get_option_set("allow_user_invites_by_roles");
+local deny_user_invite_roles = module:get_option_set("deny_user_invites_by_roles");
 
 local invites;
 if prosody.shutdown then -- COMPAT hack to detect prosodyctl
@@ -51,6 +52,12 @@
 		if not user_roles then return; end
 		if user_roles["prosody:admin"] then
 			return true;
+		elseif deny_user_invite_roles then
+			for denied_role in deny_user_invite_roles do
+				if user_roles[denied_role] then
+					return false;
+				end
+			end
 		elseif allow_user_invite_roles then
 			for allowed_role in allow_user_invite_roles do
 				if user_roles[allowed_role] then