Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 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 | 8b0a4a7d2c6e |
| children | fd6ab269ecc2 |
comparison
equal
deleted
inserted
replaced
| 3279:8b0a4a7d2c6e | 3280:eef4f31f2d7b |
|---|---|
| 899 return nil, "cancel", "not-allowed"; | 899 return nil, "cancel", "not-allowed"; |
| 900 end | 900 end |
| 901 function room_mt:set_role(actor, occupant_jid, role, callback, reason) | 901 function room_mt:set_role(actor, occupant_jid, role, callback, reason) |
| 902 if role == "none" then role = nil; end | 902 if role == "none" then role = nil; end |
| 903 if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end | 903 if role and role ~= "moderator" and role ~= "participant" and role ~= "visitor" then return nil, "modify", "not-acceptable"; end |
| 904 if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end | 904 local allowed, err_type, err_condition = self:can_set_role(actor, occupant_jid, role); |
| 905 if not allowed then return allowed, err_type, err_condition; end | |
| 905 local occupant = self._occupants[occupant_jid]; | 906 local occupant = self._occupants[occupant_jid]; |
| 906 if not occupant then return nil, "modify", "not-acceptable"; end | |
| 907 if occupant.affiliation == "owner" or occupant.affiliation == "admin" then return nil, "cancel", "not-allowed"; end | |
| 908 local p = st.presence({from = occupant_jid}) | 907 local p = st.presence({from = occupant_jid}) |
| 909 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | 908 :tag("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
| 910 :tag("item", {affiliation=occupant.affiliation or "none", nick=select(3, jid_split(occupant_jid)), role=role or "none"}) | 909 :tag("item", {affiliation=occupant.affiliation or "none", nick=select(3, jid_split(occupant_jid)), role=role or "none"}) |
| 911 :tag("reason"):text(reason or ""):up() | 910 :tag("reason"):text(reason or ""):up() |
| 912 :up(); | 911 :up(); |
