Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 6219:a90159cfa530
plugins/muc/muc.lib: Fix getting a list of occupants by role (it was sending presences instead of items inside an iq)
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Thu, 03 Apr 2014 18:10:16 -0400 |
parent | 6218:bf11910bad5a |
child | 6220:4e7d205f49f7 |
comparison
equal
deleted
inserted
replaced
6218:bf11910bad5a | 6219:a90159cfa530 |
---|---|
111 end | 111 end |
112 end | 112 end |
113 stanza.attr.to = to; | 113 stanza.attr.to = to; |
114 end | 114 end |
115 | 115 |
116 -- Adds an item to an "x" element. | |
117 -- actor is the attribute table | 116 -- actor is the attribute table |
118 local function add_item(x, affiliation, role, jid, nick, actor, reason) | 117 local function add_item(x, affiliation, role, jid, nick, actor, reason) |
119 x:tag("item", {affiliation = affiliation; role = role; jid = jid; nick = nick;}) | 118 x:tag("item", {affiliation = affiliation; role = role; jid = jid; nick = nick;}) |
120 if actor then | 119 if actor then |
121 x:tag("actor", actor):up() | 120 x:tag("actor", actor):up() |
872 origin.send(st.error_reply(stanza, "auth", "forbidden")); | 871 origin.send(st.error_reply(stanza, "auth", "forbidden")); |
873 return true; | 872 return true; |
874 end | 873 end |
875 elseif _rol and not _aff then | 874 elseif _rol and not _aff then |
876 local role = self:get_role(self:get_occupant_jid(actor)) or self:get_default_role(affiliation); | 875 local role = self:get_role(self:get_occupant_jid(actor)) or self:get_default_role(affiliation); |
877 if role == "moderator" then | 876 if valid_roles[role or "none"] >= valid_roles.moderator then |
878 if _rol == "none" then _rol = nil; end | 877 if _rol == "none" then _rol = nil; end |
879 self:send_occupant_list(actor, function(occupant_jid, occupant) return occupant.role == _rol end); | 878 local reply = st.reply(stanza):query("http://jabber.org/protocol/muc#admin"); |
879 -- TODO: whois check here? (though fully anonymous rooms are not supported) | |
880 for occupant_jid, occupant in self:each_occupant() do | |
881 if occupant.role == _rol then | |
882 local nick = select(3,jid_split(occupant_jid)); | |
883 self:build_item_list(occupant, reply, false, nick); | |
884 end | |
885 end | |
886 origin.send(reply:up()); | |
880 return true; | 887 return true; |
881 else | 888 else |
882 origin.send(st.error_reply(stanza, "auth", "forbidden")); | 889 origin.send(st.error_reply(stanza, "auth", "forbidden")); |
883 return true; | 890 return true; |
884 end | 891 end |