aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2011-08-25 12:05:27 +0500
committerWaqas Hussain <waqas20@gmail.com>2011-08-25 12:05:27 +0500
commitd22f972445b110dcf242db0285a03d5dc5ad1a96 (patch)
tree52b019c6c36428a6f1743e56756124ae1e980e6d /plugins
parenta021aa7047368a98938946022003d0e0bd728f32 (diff)
downloadprosody-d22f972445b110dcf242db0285a03d5dc5ad1a96.tar.gz
prosody-d22f972445b110dcf242db0285a03d5dc5ad1a96.zip
MUC: Allow affiliation change when argument actor==true in room:set_affiliation().
Diffstat (limited to 'plugins')
-rw-r--r--plugins/muc/muc.lib.lua30
1 files changed, 16 insertions, 14 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index ff11bd69..8e05bbb4 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -931,21 +931,23 @@ function room_mt:set_affiliation(actor, jid, affiliation, callback, reason)
if affiliation and affiliation ~= "outcast" and affiliation ~= "owner" and affiliation ~= "admin" and affiliation ~= "member" then
return nil, "modify", "not-acceptable";
end
- local actor_affiliation = self:get_affiliation(actor);
- local target_affiliation = self:get_affiliation(jid);
- if target_affiliation == affiliation then -- no change, shortcut
- if callback then callback(); end
- return true;
- end
- if actor_affiliation ~= "owner" then
- if actor_affiliation ~= "admin" or target_affiliation == "owner" or target_affiliation == "admin" then
- return nil, "cancel", "not-allowed";
+ if actor ~= true then
+ local actor_affiliation = self:get_affiliation(actor);
+ local target_affiliation = self:get_affiliation(jid);
+ if target_affiliation == affiliation then -- no change, shortcut
+ if callback then callback(); end
+ return true;
end
- elseif target_affiliation == "owner" and jid_bare(actor) == jid then -- self change
- local is_last = true;
- for j, aff in pairs(self._affiliations) do if j ~= jid and aff == "owner" then is_last = false; break; end end
- if is_last then
- return nil, "cancel", "conflict";
+ if actor_affiliation ~= "owner" then
+ if actor_affiliation ~= "admin" or target_affiliation == "owner" or target_affiliation == "admin" then
+ return nil, "cancel", "not-allowed";
+ end
+ elseif target_affiliation == "owner" and jid_bare(actor) == jid then -- self change
+ local is_last = true;
+ for j, aff in pairs(self._affiliations) do if j ~= jid and aff == "owner" then is_last = false; break; end end
+ if is_last then
+ return nil, "cancel", "conflict";
+ end
end
end
self._affiliations[jid] = affiliation;