diff options
Diffstat (limited to 'slixmpp/clientxmpp.py')
-rw-r--r-- | slixmpp/clientxmpp.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/slixmpp/clientxmpp.py b/slixmpp/clientxmpp.py index a4bb9a60..891a9fb6 100644 --- a/slixmpp/clientxmpp.py +++ b/slixmpp/clientxmpp.py @@ -15,6 +15,7 @@ import asyncio import logging +from slixmpp.jid import JID from slixmpp.stanza import StreamFeatures from slixmpp.basexmpp import BaseXMPP from slixmpp.exceptions import XMPPError @@ -108,10 +109,21 @@ class ClientXMPP(BaseXMPP): CoroutineCallback('Stream Features', MatchXPath('{%s}features' % self.stream_ns), self._handle_stream_features)) + def roster_push_filter(iq): + from_ = iq['from'] + 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 + self.event('roster_update', iq) self.register_handler( Callback('Roster Update', StanzaPath('iq@type=set/roster'), - lambda iq: self.event('roster_update', iq))) + roster_push_filter)) # Setup default stream features self.register_plugin('feature_starttls') @@ -243,7 +255,7 @@ class ClientXMPP(BaseXMPP): orig_cb(resp) callback = wrapped - iq.send(callback, timeout, timeout_callback) + return iq.send(callback, timeout, timeout_callback) def _reset_connection_state(self, event=None): #TODO: Use stream state here |