aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-06-19 23:35:53 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-06-19 23:35:53 +0500
commit178b5282e806bae8b13f07c3822caeebc44c1787 (patch)
tree98d6afcb8acda6e51a50a27e4fc6d46e2e691b4c
parent29fd792c7f3c41c34eb85eeec2fb4d284f83f158 (diff)
downloadprosody-178b5282e806bae8b13f07c3822caeebc44c1787.tar.gz
prosody-178b5282e806bae8b13f07c3822caeebc44c1787.zip
MUC: Added room:can_set_role().
-rw-r--r--plugins/muc/muc.lib.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 08a66c4d..6800aca6 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -881,6 +881,23 @@ function room_mt:get_role(nick)
local session = self._occupants[nick];
return session and session.role or nil;
end
+function room_mt:can_set_role(actor_jid, occupant_jid, role)
+ local actor = self._occupants[self._jid_nick[actor_jid]];
+ local occupant = self._occupants[occupant_jid];
+
+ if not occupant or not actor then return nil, "modify", "not-acceptable"; end
+
+ if actor.role == "moderator" then
+ if occupant.affiliation ~= "owner" and occupant.affiliation ~= "admin" then
+ if actor.affiliation == "owner" or actor.affiliation == "admin" then
+ return true;
+ elseif occupant.role ~= "moderator" and role ~= "moderator" then
+ return true;
+ end
+ end
+ end
+ return nil, "cancel", "not-allowed";
+end
function room_mt:set_role(actor, occupant_jid, role, callback, reason)
if role == "none" then role = nil; end
if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end