Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 4203:e3d937eec3fa
Merge 0.8->trunk.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 24 Feb 2011 19:30:26 +0500 (2011-02-24) |
parent | 4202:dff7df4a191b |
child | 4266:513485a11b85 |
comparison
equal
deleted
inserted
replaced
4200:fb487ee690ea | 4203:e3d937eec3fa |
---|---|
796 elseif type == "set" or type == "get" then | 796 elseif type == "set" or type == "get" then |
797 origin.send(st.error_reply(stanza, "cancel", "bad-request")); | 797 origin.send(st.error_reply(stanza, "cancel", "bad-request")); |
798 end | 798 end |
799 elseif xmlns == "http://jabber.org/protocol/muc#owner" and (type == "get" or type == "set") and stanza.tags[1].name == "query" then | 799 elseif xmlns == "http://jabber.org/protocol/muc#owner" and (type == "get" or type == "set") and stanza.tags[1].name == "query" then |
800 if self:get_affiliation(stanza.attr.from) ~= "owner" then | 800 if self:get_affiliation(stanza.attr.from) ~= "owner" then |
801 origin.send(st.error_reply(stanza, "auth", "forbidden")); | 801 origin.send(st.error_reply(stanza, "auth", "forbidden", "Only owners can configure rooms")); |
802 elseif stanza.attr.type == "get" then | 802 elseif stanza.attr.type == "get" then |
803 self:send_form(origin, stanza); | 803 self:send_form(origin, stanza); |
804 elseif stanza.attr.type == "set" then | 804 elseif stanza.attr.type == "set" then |
805 local child = stanza.tags[1].tags[1]; | 805 local child = stanza.tags[1].tags[1]; |
806 if not child then | 806 if not child then |
927 jid = jid_bare(jid); | 927 jid = jid_bare(jid); |
928 if affiliation == "none" then affiliation = nil; end | 928 if affiliation == "none" then affiliation = nil; end |
929 if affiliation and affiliation ~= "outcast" and affiliation ~= "owner" and affiliation ~= "admin" and affiliation ~= "member" then | 929 if affiliation and affiliation ~= "outcast" and affiliation ~= "owner" and affiliation ~= "admin" and affiliation ~= "member" then |
930 return nil, "modify", "not-acceptable"; | 930 return nil, "modify", "not-acceptable"; |
931 end | 931 end |
932 if self:get_affiliation(actor) ~= "owner" then return nil, "cancel", "not-allowed"; end | 932 local actor_affiliation = self:get_affiliation(actor); |
933 if jid_bare(actor) == jid then return nil, "cancel", "not-allowed"; end | 933 local target_affiliation = self:get_affiliation(jid); |
934 if target_affiliation == affiliation then -- no change, shortcut | |
935 if callback then callback(); end | |
936 return true; | |
937 end | |
938 if actor_affiliation ~= "owner" then | |
939 if actor_affiliation ~= "admin" or target_affiliation == "owner" or target_affiliation == "admin" then | |
940 return nil, "cancel", "not-allowed"; | |
941 end | |
942 elseif target_affiliation == "owner" and jid_bare(actor) == jid then -- self change | |
943 local is_last = true; | |
944 for j, aff in pairs(self._affiliations) do if j ~= jid and aff == "owner" then is_last = false; break; end end | |
945 if is_last then | |
946 return nil, "cancel", "conflict"; | |
947 end | |
948 end | |
934 self._affiliations[jid] = affiliation; | 949 self._affiliations[jid] = affiliation; |
935 local role = self:get_default_role(affiliation); | 950 local role = self:get_default_role(affiliation); |
936 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | 951 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
937 :tag("item", {affiliation=affiliation or "none", role=role or "none"}) | 952 :tag("item", {affiliation=affiliation or "none", role=role or "none"}) |
938 :tag("reason"):text(reason or ""):up() | 953 :tag("reason"):text(reason or ""):up() |