aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2011-02-24 19:30:26 +0500
committerWaqas Hussain <waqas20@gmail.com>2011-02-24 19:30:26 +0500
commite008d0b29f65fbd6497991c4d7ee479234847a22 (patch)
treeb499eb3ad086df896b7231eb7f49bdbeaa39a206 /plugins
parent41fadd96a18cb6ecb3d9a5bc92dfd3361138968a (diff)
parent88b861e694d0e03a2dc2b8d69019baaa70caa154 (diff)
downloadprosody-e008d0b29f65fbd6497991c4d7ee479234847a22.tar.gz
prosody-e008d0b29f65fbd6497991c4d7ee479234847a22.zip
Merge 0.8->trunk.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/muc/muc.lib.lua21
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 8bbf0df2..647bf915 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -798,7 +798,7 @@ function room_mt:handle_to_room(origin, stanza) -- presence changes and groupcha
end
elseif xmlns == "http://jabber.org/protocol/muc#owner" and (type == "get" or type == "set") and stanza.tags[1].name == "query" then
if self:get_affiliation(stanza.attr.from) ~= "owner" then
- origin.send(st.error_reply(stanza, "auth", "forbidden"));
+ origin.send(st.error_reply(stanza, "auth", "forbidden", "Only owners can configure rooms"));
elseif stanza.attr.type == "get" then
self:send_form(origin, stanza);
elseif stanza.attr.type == "set" then
@@ -929,8 +929,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
- if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end
- if jid_bare(actor) == jid then return nil, "cancel", "not-allowed"; 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";
+ 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
self._affiliations[jid] = affiliation;
local role = self:get_default_role(affiliation);
local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"})