Fix roster push origin detection and tests

This commit is contained in:
mathieui 2016-12-07 19:06:25 +01:00
parent bbb1344d79
commit ffd9436e5c

View File

@ -15,6 +15,7 @@
import asyncio import asyncio
import logging import logging
from slixmpp.jid import JID
from slixmpp.stanza import StreamFeatures from slixmpp.stanza import StreamFeatures
from slixmpp.basexmpp import BaseXMPP from slixmpp.basexmpp import BaseXMPP
from slixmpp.exceptions import XMPPError from slixmpp.exceptions import XMPPError
@ -110,7 +111,13 @@ class ClientXMPP(BaseXMPP):
self._handle_stream_features)) self._handle_stream_features))
def roster_push_filter(iq): def roster_push_filter(iq):
from_ = iq['from'] from_ = iq['from']
if from_ and from_ != self.boundjid.bare: if from_ and from_ != JID('') and from_ != self.boundjid.bare:
reply = iq.reply()
reply['type'] = 'error'
reply['error']['type'] = 'cancel'
reply['error']['code'] = 503
reply['error']['condition'] = 'service-unavailable'
reply.send()
return return
self.event('roster_update', iq) self.event('roster_update', iq)
self.register_handler( self.register_handler(