plugins/muc/muc.lib: In `_route_stanza` access occupant data less often
authordaurnimator <quae@daurnimator.com>
Wed, 19 Mar 2014 18:35:17 +0000 (14:35 -0400)
committerdaurnimator <quae@daurnimator.com>
Wed, 19 Mar 2014 18:35:17 +0000 (14:35 -0400)
plugins/muc/muc.lib.lua

index 2fb1a34ef62f462ca36f53829f2bceb82fe06042..1a5bc9762c1de918e8a76f6e4545885f2dbf9981 100644 (file)
@@ -1210,9 +1210,9 @@ end
 
 function room_mt:_route_stanza(stanza)
        local muc_child;
-       local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]];
-       local from_occupant = self._occupants[stanza.attr.from];
        if stanza.name == "presence" then
+               local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]];
+               local from_occupant = self._occupants[stanza.attr.from];
                if to_occupant and from_occupant then
                        if self._data.whois == 'anyone' then
                            muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
@@ -1222,13 +1222,13 @@ function room_mt:_route_stanza(stanza)
                                end
                        end
                end
-       end
-       if muc_child then
-               for item in muc_child:childtags("item") do
-                       if from_occupant == to_occupant then
-                               item.attr.jid = stanza.attr.to;
-                       else
-                               item.attr.jid = from_occupant.jid;
+               if muc_child then
+                       for item in muc_child:childtags("item") do
+                               if from_occupant == to_occupant then
+                                       item.attr.jid = stanza.attr.to;
+                               else
+                                       item.attr.jid = from_occupant.jid;
+                               end
                        end
                end
        end