Commit d93fe8b1 authored by Philipp Hörist's avatar Philipp Hörist

HTTPAuth: Use nbxmpp handlers

parent d121bbf4
......@@ -297,10 +297,6 @@ class ConnectionHandlers(ConnectionSocks5Bytestream,
stanza=iq_obj))
def _IqCB(self, con, iq_obj, properties):
if properties.is_http_auth:
self.get_module('HTTPAuth').delegate(iq_obj, properties)
raise nbxmpp.NodeProcessed
id_ = iq_obj.getID()
app.nec.push_incoming_event(NetworkEvent('raw-iq-received',
......
......@@ -17,6 +17,8 @@
import logging
import nbxmpp
from nbxmpp.structs import StanzaHandler
from nbxmpp.protocol import NS_HTTP_AUTH
from gajim.common import app
from gajim.common.nec import NetworkEvent
......@@ -29,9 +31,22 @@ class HTTPAuth:
self._con = con
self._account = con.name
self.handlers = []
self.handlers = [
StanzaHandler(name='message',
callback=self._http_auth,
ns=NS_HTTP_AUTH,
priority=45),
StanzaHandler(name='iq',
callback=self._http_auth,
typ='get',
ns=NS_HTTP_AUTH,
priority=45)
]
def _http_auth(self, _con, stanza, properties):
if not properties.is_http_auth:
return
def delegate(self, stanza, properties):
log.info('Auth request received')
auto_answer = app.config.get_per(
'accounts', self._account, 'http_auth')
......@@ -42,11 +57,12 @@ class HTTPAuth:
app.nec.push_incoming_event(
NetworkEvent('http-auth-received',
conn=self._con,
iq_id=properties['id'],
method=properties['method'],
url=properties['url'],
msg=properties['body'],
iq_id=properties.http_auth.id,
method=properties.http_auth.method,
url=properties.http_auth.url,
msg=properties.http_auth.body,
stanza=stanza))
raise nbxmpp.NodeProcessed
def build_http_auth_answer(self, stanza, answer):
if answer == 'yes':
......
......@@ -58,10 +58,6 @@ class Message:
nbxmpp.NS_CAPTCHA,])
def _message_received(self, _con, stanza, properties):
if properties.is_http_auth:
self._con.get_module('HTTPAuth').delegate(stanza, properties)
raise nbxmpp.NodeProcessed
# Check if a child of the message contains any
# namespaces that we handle in other modules.
# nbxmpp executes less common handlers last
......
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