diff 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
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0060.py	Wed Nov 25 15:35:21 2015 +0100
+++ b/src/plugins/plugin_xep_0060.py	Wed Nov 25 16:59:13 2015 +0100
@@ -25,7 +25,7 @@
 
 from sat.tools import sat_defer
 
-from twisted.words.protocols.jabber import jid
+from twisted.words.protocols.jabber import jid, error
 from twisted.internet import defer
 from wokkel import disco
 # XXX: tmp.pubsub is actually use instead of wokkel version
@@ -244,8 +244,12 @@
         except KeyError:
             subscribe = False
 
+        def subscribeEb(failure, service, node):
+            failure.trap(error.StanzaError)
+            log.warning("Could not subscribe to node {} on service {}: {}".format(node, unicode(service), unicode(failure.value)))
+            
         def doSubscribe(items):
-            self.subscribe(service, node, profile_key=profile_key)
+            self.subscribe(service, node, profile_key=profile_key).addErrback(subscribeEb, service, node)
             return items
 
         if subscribe: