Mercurial > prosody-modules
comparison mod_invites_adhoc/mod_invites_adhoc.lua @ 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 | d1230d32d709 |
children | ea93b204104e |
comparison
equal
deleted
inserted
replaced
4765:3632836f35b0 | 4766:abac64f71698 |
---|---|
12 -- keep this available to all local users. To allow/disallow invite-registration | 12 -- keep this available to all local users. To allow/disallow invite-registration |
13 -- on the server, use the option above instead. | 13 -- on the server, use the option above instead. |
14 local allow_contact_invites = module:get_option_boolean("allow_contact_invites", true); | 14 local allow_contact_invites = module:get_option_boolean("allow_contact_invites", true); |
15 | 15 |
16 local allow_user_invite_roles = module:get_option_set("allow_user_invites_by_roles"); | 16 local allow_user_invite_roles = module:get_option_set("allow_user_invites_by_roles"); |
17 local deny_user_invite_roles = module:get_option_set("deny_user_invites_by_roles"); | |
17 | 18 |
18 local invites; | 19 local invites; |
19 if prosody.shutdown then -- COMPAT hack to detect prosodyctl | 20 if prosody.shutdown then -- COMPAT hack to detect prosodyctl |
20 invites = module:depends("invites"); | 21 invites = module:depends("invites"); |
21 end | 22 end |
49 if usermanager.get_roles then | 50 if usermanager.get_roles then |
50 local user_roles = usermanager.get_roles(jid, module.host); | 51 local user_roles = usermanager.get_roles(jid, module.host); |
51 if not user_roles then return; end | 52 if not user_roles then return; end |
52 if user_roles["prosody:admin"] then | 53 if user_roles["prosody:admin"] then |
53 return true; | 54 return true; |
55 elseif deny_user_invite_roles then | |
56 for denied_role in deny_user_invite_roles do | |
57 if user_roles[denied_role] then | |
58 return false; | |
59 end | |
60 end | |
54 elseif allow_user_invite_roles then | 61 elseif allow_user_invite_roles then |
55 for allowed_role in allow_user_invite_roles do | 62 for allowed_role in allow_user_invite_roles do |
56 if user_roles[allowed_role] then | 63 if user_roles[allowed_role] then |
57 return true; | 64 return true; |
58 end | 65 end |