diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 089fbd69b..2dbff985b 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -2733,8 +2733,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, con.RegisterHandler('message', self._messageCB) con.RegisterHandler('presence', self._presenceCB) con.RegisterHandler('presence', self._capsPresenceCB) - con.RegisterHandler('message', self._pubsubEventCB, - ns=common.xmpp.NS_PUBSUB_EVENT) + # We use makefirst so that this handler is called before _messageCB, and + # can prevent calling it when it's not needed. + # We also don't check for namespace, else it cannot stop _messageCB to be + # called + con.RegisterHandler('message', self._pubsubEventCB, makefirst=True) con.RegisterHandler('iq', self._vCardCB, 'result', common.xmpp.NS_VCARD) con.RegisterHandler('iq', self._rosterSetCB, 'set', diff --git a/src/common/pep.py b/src/common/pep.py index 34f3bda46..5ba476c0c 100644 --- a/src/common/pep.py +++ b/src/common/pep.py @@ -454,6 +454,8 @@ class ConnectionPEP(object): def _pubsubEventCB(self, xmpp_dispatcher, msg): ''' Called when we receive with pubsub event. ''' + if not msg.getTag('event'): + return if msg.getTag('error'): log.debug('PubsubEventCB received error stanza. Ignoring') raise xmpp.NodeProcessed