comparison src/plugins/plugin_xep_0060.py @ 1678:c2d96f74105e

plugin XEP-0060: trap failure when subscription to a node is not possible
author souliane <souliane@mailoo.org>
date Wed, 25 Nov 2015 16:59:13 +0100
parents e0bde0d0b321
children 30efe084471c
comparison
equal deleted inserted replaced
1677:a125b11af711 1678:c2d96f74105e
23 log = getLogger(__name__) 23 log = getLogger(__name__)
24 from sat.core import exceptions 24 from sat.core import exceptions
25 25
26 from sat.tools import sat_defer 26 from sat.tools import sat_defer
27 27
28 from twisted.words.protocols.jabber import jid 28 from twisted.words.protocols.jabber import jid, error
29 from twisted.internet import defer 29 from twisted.internet import defer
30 from wokkel import disco 30 from wokkel import disco
31 # XXX: tmp.pubsub is actually use instead of wokkel version 31 # XXX: tmp.pubsub is actually use instead of wokkel version
32 # same thing for rsm 32 # same thing for rsm
33 from wokkel import pubsub 33 from wokkel import pubsub
242 try: 242 try:
243 subscribe = C.bool(extra['subscribe']) 243 subscribe = C.bool(extra['subscribe'])
244 except KeyError: 244 except KeyError:
245 subscribe = False 245 subscribe = False
246 246
247 def subscribeEb(failure, service, node):
248 failure.trap(error.StanzaError)
249 log.warning("Could not subscribe to node {} on service {}: {}".format(node, unicode(service), unicode(failure.value)))
250
247 def doSubscribe(items): 251 def doSubscribe(items):
248 self.subscribe(service, node, profile_key=profile_key) 252 self.subscribe(service, node, profile_key=profile_key).addErrback(subscribeEb, service, node)
249 return items 253 return items
250 254
251 if subscribe: 255 if subscribe:
252 d.addCallback(doSubscribe) 256 d.addCallback(doSubscribe)
253 257