aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/members_only.lib.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-07-07 16:54:44 +0100
committerMatthew Wild <mwild1@gmail.com>2018-07-07 16:54:44 +0100
commit299cca0b3f3823f9928f46275b96f7858a77b3c3 (patch)
tree5dc067ee3d79ce2327fb2df619b91c41d83def8c /plugins/muc/members_only.lib.lua
parent3967be1ab733cbc5e251f8daa2942ed82cfa1d0d (diff)
downloadprosody-299cca0b3f3823f9928f46275b96f7858a77b3c3.tar.gz
prosody-299cca0b3f3823f9928f46275b96f7858a77b3c3.zip
MUC: Clarify logic of invitations in members-only rooms
Diffstat (limited to 'plugins/muc/members_only.lib.lua')
-rw-r--r--plugins/muc/members_only.lib.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/muc/members_only.lib.lua b/plugins/muc/members_only.lib.lua
index 0cd68d08..c9980280 100644
--- a/plugins/muc/members_only.lib.lua
+++ b/plugins/muc/members_only.lib.lua
@@ -127,8 +127,9 @@ module:hook("muc-pre-invite", function(event)
local room = event.room;
if get_members_only(room) then
local stanza = event.stanza;
- local affiliation = room:get_affiliation(stanza.attr.from);
- if not room._data.allow_member_invites and valid_affiliations[affiliation or "none"] < valid_affiliations.admin then
+ local inviter_affiliation = room:get_affiliation(stanza.attr.from) or "none";
+ local required_affiliation = room._data.allow_member_invites and "member" or "admin";
+ if valid_affiliations[inviter_affiliation] < valid_affiliations[required_affiliation] then
event.origin.send(st.error_reply(stanza, "auth", "forbidden"));
return true;
end
@@ -142,7 +143,8 @@ module:hook("muc-invite", function(event)
local stanza = event.stanza;
local invitee = stanza.attr.to;
local affiliation = room:get_affiliation(invitee);
- if valid_affiliations[affiliation or "none"] <= valid_affiliations.none and room._data.allow_member_invites then
+ local invited_unaffiliated = valid_affiliations[affiliation or "none"] <= valid_affiliations.none;
+ if invited_unaffiliated then
local from = stanza:get_child("x", "http://jabber.org/protocol/muc#user")
:get_child("invite").attr.from;
module:log("debug", "%s invited %s into members only room %s, granting membership",