# HG changeset patch # User Matthew Wild # Date 1530978884 -3600 # Node ID 596c8c7d98b1cfaaa6fa6fade1aea31e1faf6cc3 # Parent 320ae6dbb2e8eea29bf4e8e8a3e4a13085b02bdb MUC: Clarify logic of invitations in members-only rooms diff -r 320ae6dbb2e8 -r 596c8c7d98b1 plugins/muc/members_only.lib.lua --- a/plugins/muc/members_only.lib.lua Sat Jul 07 12:14:29 2018 +0100 +++ b/plugins/muc/members_only.lib.lua Sat Jul 07 16:54:44 2018 +0100 @@ -127,8 +127,9 @@ 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 @@ 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",