Changeset

3280:eef4f31f2d7b

MUC: Updated room:set_role() to use room:can_set_role().
author Waqas Hussain <waqas20@gmail.com>
date Sat, 19 Jun 2010 23:38:25 +0500
parents 3279:8b0a4a7d2c6e
children 3281:fd6ab269ecc2
files plugins/muc/muc.lib.lua
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Sat Jun 19 23:35:53 2010 +0500
+++ b/plugins/muc/muc.lib.lua	Sat Jun 19 23:38:25 2010 +0500
@@ -901,10 +901,9 @@
 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
-	if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end
+	local allowed, err_type, err_condition = self:can_set_role(actor, occupant_jid, role);
+	if not allowed then return allowed, err_type, err_condition; end
 	local occupant = self._occupants[occupant_jid];
-	if not occupant then return nil, "modify", "not-acceptable"; end
-	if occupant.affiliation == "owner" or occupant.affiliation == "admin" then return nil, "cancel", "not-allowed"; end
 	local p = st.presence({from = occupant_jid})
 		:tag("x", {xmlns = "http://jabber.org/protocol/muc#user"})
 			:tag("item", {affiliation=occupant.affiliation or "none", nick=select(3, jid_split(occupant_jid)), role=role or "none"})