Add message handlers for AUTH and ROSTERX
This commit is contained in:
parent
fe3c1b4fbd
commit
503ee35bd0
|
@ -302,6 +302,11 @@ class ConnectionHandlersBase:
|
||||||
# We decrypt GPG messages one after the other. Keep queue in mem
|
# We decrypt GPG messages one after the other. Keep queue in mem
|
||||||
self.gpg_messages_to_decrypt = []
|
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,
|
app.ged.register_event_handler('iq-error-received', ged.CORE,
|
||||||
self._nec_iq_error_received)
|
self._nec_iq_error_received)
|
||||||
app.ged.register_event_handler('presence-received', ged.CORE,
|
app.ged.register_event_handler('presence-received', ged.CORE,
|
||||||
|
@ -1023,7 +1028,13 @@ ConnectionHTTPUpload):
|
||||||
"""
|
"""
|
||||||
Called when we receive a message
|
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
|
return
|
||||||
log.debug('MessageCB')
|
log.debug('MessageCB')
|
||||||
|
|
||||||
|
|
|
@ -914,18 +914,6 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
self.stanza.getFrom())
|
self.stanza.getFrom())
|
||||||
return
|
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:
|
try:
|
||||||
self.get_jid_resource()
|
self.get_jid_resource()
|
||||||
except helpers.InvalidFormat:
|
except helpers.InvalidFormat:
|
||||||
|
|
|
@ -30,7 +30,8 @@ class HTTPAuth:
|
||||||
self._account = con.name
|
self._account = con.name
|
||||||
|
|
||||||
self.handlers = [
|
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):
|
def answer_request(self, con, stanza):
|
||||||
|
|
|
@ -31,7 +31,8 @@ class RosterItemExchange:
|
||||||
self._account = con.name
|
self._account = con.name
|
||||||
|
|
||||||
self.handlers = [
|
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):
|
def received_item(self, con, stanza):
|
||||||
|
|
Loading…
Reference in New Issue