comparison 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
comparison
equal deleted inserted replaced
434:f6a225476165 435:96342e7e9f5d
28 from wokkel.iwokkel import IPubSubService 28 from wokkel.iwokkel import IPubSubService
29 from twisted.python import log 29 from twisted.python import log
30 from twisted.python import failure 30 from twisted.python import failure
31 from twisted.internet import defer 31 from twisted.internet import defer
32 from twisted.words.xish import domish 32 from twisted.words.xish import domish
33 from twisted.words.protocols.jabber import jid 33 from twisted.words.protocols.jabber import jid, error
34 import time 34 import time
35 35
36 FORWARDED_NS = 'urn:xmpp:forward:0' 36 FORWARDED_NS = 'urn:xmpp:forward:0'
37 PRIV_ENT_NS = 'urn:xmpp:privilege:1' 37 PRIV_ENT_NS = 'urn:xmpp:privilege:1'
38 PRIV_ENT_ADV_XPATH = '/message/privilege[@xmlns="{}"]'.format(PRIV_ENT_NS) 38 PRIV_ENT_ADV_XPATH = '/message/privilege[@xmlns="{}"]'.format(PRIV_ENT_NS)
256 # FIXME: hash is not checked (cf. XEP-0115) 256 # FIXME: hash is not checked (cf. XEP-0115)
257 disco_tuple = (hash_, ver) 257 disco_tuple = (hash_, ver)
258 258
259 if disco_tuple not in self.hash_map: 259 if disco_tuple not in self.hash_map:
260 # first time we se this hash, what is behind it? 260 # first time we se this hash, what is behind it?
261 infos = yield self.requestInfo(from_jid) 261 try:
262 self.hash_map[disco_tuple] = { 262 infos = yield self.requestInfo(from_jid)
263 'notify': {f[:-7] for f in infos.features if f.endswith('+notify')}, 263 except error.StanzaError as e:
264 'infos': infos 264 log.msg(
265 f"WARNING: can't request disco info for {from_jid!r} (presence: "
266 f"{presence_type}): {e}"
267 )
268 else:
269 self.hash_map[disco_tuple] = {
270 'notify': {
271 f[:-7] for f in infos.features if f.endswith('+notify')
272 },
273 'infos': infos
265 } 274 }
266 275
267 # jid_caps must be filled only after hash_map is set, to be sure that 276 # jid_caps must be filled only after hash_map is set, to be sure that
268 # the hash data is available in getAutoSubscribers 277 # the hash data is available in getAutoSubscribers
269 jid_caps = self.caps_map.setdefault(from_jid_bare, {}) 278 jid_caps = self.caps_map.setdefault(from_jid_bare, {})