749 return session and session.role or nil; |
749 return session and session.role or nil; |
750 end |
750 end |
751 function room_mt:set_role(actor, occupant_jid, role, callback, reason) |
751 function room_mt:set_role(actor, occupant_jid, role, callback, reason) |
752 if role == "none" then role = nil; end |
752 if role == "none" then role = nil; end |
753 if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end |
753 if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end |
754 if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end |
754 if self:get_role(self._jid_nick[actor]) ~= "moderator" then return nil, "cancel", "not-allowed"; end |
755 local occupant = self._occupants[occupant_jid]; |
755 local occupant = self._occupants[occupant_jid]; |
756 if not occupant then return nil, "modify", "not-acceptable"; end |
756 if not occupant then return nil, "modify", "not-acceptable"; end |
757 if occupant.affiliation == "owner" or occupant.affiliation == "admin" then return nil, "cancel", "not-allowed"; end |
757 if occupant.affiliation == "owner" or occupant.affiliation == "admin" then return nil, "cancel", "not-allowed"; end |
758 local p = st.presence({from = occupant_jid}) |
758 local p = st.presence({from = occupant_jid}) |
759 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
759 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |