Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 2416:89be536aae25
mod_muc/muc.lib: Use stanza:get_child() to locate MUC child element
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 03 Jan 2010 17:53:54 +0000 |
| parents | e243b7c81de6 |
| children | bb6b0bd7f2cf |
comparison
equal
deleted
inserted
replaced
| 2413:feb46e05d498 | 2416:89be536aae25 |
|---|---|
| 775 if callback then callback(); end | 775 if callback then callback(); end |
| 776 self:broadcast_except_nick(p, nick); | 776 self:broadcast_except_nick(p, nick); |
| 777 return true; | 777 return true; |
| 778 end | 778 end |
| 779 | 779 |
| 780 local function _get_muc_child(stanza) | |
| 781 for i=#stanza.tags,1,-1 do | |
| 782 local tag = stanza.tags[i]; | |
| 783 if tag.name == "x" and tag.attr.xmlns == "http://jabber.org/protocol/muc#user" then | |
| 784 return tag; | |
| 785 end | |
| 786 end | |
| 787 end | |
| 788 | |
| 789 function room_mt:_route_stanza(stanza) | 780 function room_mt:_route_stanza(stanza) |
| 790 local muc_child; | 781 local muc_child; |
| 791 local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]]; | 782 local to_occupant = self._occupants[self._jid_nick[stanza.attr.to]]; |
| 792 local from_occupant = self._occupants[stanza.attr.from]; | 783 local from_occupant = self._occupants[stanza.attr.from]; |
| 793 if stanza.name == "presence" then | 784 if stanza.name == "presence" then |
| 794 if to_occupant and from_occupant then | 785 if to_occupant and from_occupant then |
| 795 if self._data.whois == 'anyone' then | 786 if self._data.whois == 'anyone' then |
| 796 muc_child = _get_muc_child(stanza) | 787 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); |
| 797 else | 788 else |
| 798 if to_occupant.role == "moderator" or jid_bare(to_occupant.jid) == jid_bare(from_occupant.jid) then | 789 if to_occupant.role == "moderator" or jid_bare(to_occupant.jid) == jid_bare(from_occupant.jid) then |
| 799 muc_child = _get_muc_child(stanza) | 790 muc_child = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); |
| 800 end | 791 end |
| 801 end | 792 end |
| 802 end | 793 end |
| 803 end | 794 end |
| 804 if muc_child then | 795 if muc_child then |
