diff sat_pubsub/privilege.py @ 435:96342e7e9f5d

privilege: log error when `requestInfo` is failing
author Goffi <goffi@goffi.org>
date Thu, 04 Feb 2021 09:54:53 +0100
parents ccb2a22ea0fc
children 0b5233981671
line wrap: on
line diff
--- a/sat_pubsub/privilege.py	Thu Feb 04 09:38:17 2021 +0100
+++ b/sat_pubsub/privilege.py	Thu Feb 04 09:54:53 2021 +0100
@@ -30,7 +30,7 @@
 from twisted.python import failure
 from twisted.internet import defer
 from twisted.words.xish import domish
-from twisted.words.protocols.jabber import jid
+from twisted.words.protocols.jabber import jid, error
 import time
 
 FORWARDED_NS = 'urn:xmpp:forward:0'
@@ -258,10 +258,19 @@
 
             if disco_tuple not in self.hash_map:
                 # first time we se this hash, what is behind it?
-                infos = yield self.requestInfo(from_jid)
-                self.hash_map[disco_tuple] = {
-                    'notify': {f[:-7] for f in infos.features if f.endswith('+notify')},
-                    'infos': infos
+                try:
+                    infos = yield self.requestInfo(from_jid)
+                except error.StanzaError as e:
+                    log.msg(
+                        f"WARNING: can't request disco info for {from_jid!r} (presence: "
+                        f"{presence_type}): {e}"
+                    )
+                else:
+                    self.hash_map[disco_tuple] = {
+                        'notify': {
+                            f[:-7] for f in infos.features if f.endswith('+notify')
+                        },
+                        'infos': infos
                     }
 
             # jid_caps must be filled only after hash_map is set, to be sure that