Add message handlers for AUTH and ROSTERX

This commit is contained in:
Philipp Hörist 2018-07-05 21:09:55 +02:00
parent fe3c1b4fbd
commit 503ee35bd0
4 changed files with 16 additions and 15 deletions

View File

@ -302,6 +302,11 @@ class ConnectionHandlersBase:
# We decrypt GPG messages one after the other. Keep queue in mem
self.gpg_messages_to_decrypt = []
# XEPs that are based on Message
self._message_namespaces = set([nbxmpp.NS_HTTP_AUTH,
nbxmpp.NS_PUBSUB_EVENT,
nbxmpp.NS_ROSTERX])
app.ged.register_event_handler('iq-error-received', ged.CORE,
self._nec_iq_error_received)
app.ged.register_event_handler('presence-received', ged.CORE,
@ -1023,7 +1028,13 @@ ConnectionHTTPUpload):
"""
Called when we receive a message
"""
if nbxmpp.NS_PUBSUB_EVENT in stanza.getProperties():
# Check if a child of the message contains any
# of these namespaces, so we dont execute the
# message handler for them.
# They have defined their own message handlers
# but nbxmpp executes less common handlers last
if self._message_namespaces & set(stanza.getProperties()):
return
log.debug('MessageCB')

View File

@ -914,18 +914,6 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.stanza.getFrom())
return
# check if the message is a roster item exchange (XEP-0144)
if self.stanza.getTag('x', namespace=nbxmpp.NS_ROSTERX):
self.conn.get_module('RosterItemExchange').received_item(
self.conn, self.stanza)
return
# check if the message is a XEP-0070 confirmation request
if self.stanza.getTag('confirm', namespace=nbxmpp.NS_HTTP_AUTH):
self.conn.get_module('HTTPAuth').answer_request(
self.conn, self.stanza)
return
try:
self.get_jid_resource()
except helpers.InvalidFormat:

View File

@ -30,7 +30,8 @@ class HTTPAuth:
self._account = con.name
self.handlers = [
('iq', self.answer_request, 'get', nbxmpp.NS_HTTP_AUTH)
('iq', self.answer_request, 'get', nbxmpp.NS_HTTP_AUTH),
('message', self.answer_request, '', nbxmpp.NS_HTTP_AUTH)
]
def answer_request(self, con, stanza):

View File

@ -31,7 +31,8 @@ class RosterItemExchange:
self._account = con.name
self.handlers = [
('iq', self.received_item, 'set', nbxmpp.NS_ROSTERX)
('iq', self.received_item, 'set', nbxmpp.NS_ROSTERX),
('message', self.received_item, '', nbxmpp.NS_ROSTERX)
]
def received_item(self, con, stanza):