Comparison

plugins/muc/muc.lib.lua @ 6117:d7ade0b00ec5

plugins/muc/muc.lib: In `_route_stanza` access occupant data less often
author daurnimator <quae@daurnimator.com>
date Wed, 19 Mar 2014 14:35:17 -0400
parent 6116:9147e566fde0
child 6118:aae3d6daa50d
comparison
equal deleted inserted replaced
6116:9147e566fde0 6117:d7ade0b00ec5
1208 return true; 1208 return true;
1209 end 1209 end
1210 1210
1211 function room_mt:_route_stanza(stanza) 1211 function room_mt:_route_stanza(stanza)
1212 local muc_child; 1212 local muc_child;
1213 local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]];
1214 local from_occupant = self._occupants[stanza.attr.from];
1215 if stanza.name == "presence" then 1213 if stanza.name == "presence" then
1214 local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]];
1215 local from_occupant = self._occupants[stanza.attr.from];
1216 if to_occupant and from_occupant then 1216 if to_occupant and from_occupant then
1217 if self._data.whois == 'anyone' then 1217 if self._data.whois == 'anyone' then
1218 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); 1218 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
1219 else 1219 else
1220 if to_occupant.role == "moderator" or jid_bare(to_occupant.jid) == jid_bare(from_occupant.jid) then 1220 if to_occupant.role == "moderator" or jid_bare(to_occupant.jid) == jid_bare(from_occupant.jid) then
1221 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); 1221 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
1222 end 1222 end
1223 end 1223 end
1224 end 1224 end
1225 end 1225 if muc_child then
1226 if muc_child then 1226 for item in muc_child:childtags("item") do
1227 for item in muc_child:childtags("item") do 1227 if from_occupant == to_occupant then
1228 if from_occupant == to_occupant then 1228 item.attr.jid = stanza.attr.to;
1229 item.attr.jid = stanza.attr.to; 1229 else
1230 else 1230 item.attr.jid = from_occupant.jid;
1231 item.attr.jid = from_occupant.jid; 1231 end
1232 end 1232 end
1233 end 1233 end
1234 end 1234 end
1235 self:route_stanza(stanza); 1235 self:route_stanza(stanza);
1236 if muc_child then 1236 if muc_child then