Commit 503ee35b authored by Philipp Hörist's avatar Philipp Hörist

Add message handlers for AUTH and ROSTERX

parent fe3c1b4f
......@@ -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')
......
......@@ -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:
......
......@@ -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):
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment