plugin XEP-0384: fixed exception catching on getItems

This commit is contained in:
Goffi 2020-01-29 18:31:47 +01:00
commit c00fe7f1e6

View file

@ -634,11 +634,9 @@ class OMEMO(object):
assert not entity_jid.resource
try:
items, metadata = yield self._p.getItems(client, entity_jid, NS_OMEMO_DEVICES)
except error.StanzaError as e:
if e.condition == 'item-not-found':
log.info(_("there is no node to handle OMEMO devices"))
defer.returnValue(set())
raise e
except exceptions.NotFound:
log.info(_("there is no node to handle OMEMO devices"))
defer.returnValue(set())
devices = self.parseDevices(items)
defer.returnValue(devices)
@ -677,16 +675,15 @@ class OMEMO(object):
node = NS_OMEMO_BUNDLE.format(device_id=device_id)
try:
items, metadata = yield self._p.getItems(client, entity_jid, node)
except exceptions.NotFound:
log.warning(_("Bundle missing for device {device_id}")
.format(device_id=device_id))
missing.add(device_id)
continue
except error.StanzaError as e:
if e.condition == "item-not-found":
log.warning(_("Bundle missing for device {device_id}")
.format(device_id=device_id))
missing.add(device_id)
continue
else:
log.warning(_("Can't get bundle for device {device_id}: {reason}")
.format(device_id=device_id, reason=e))
continue
log.warning(_("Can't get bundle for device {device_id}: {reason}")
.format(device_id=device_id, reason=e))
continue
if not items:
log.warning(_("no item found in node {node}, can't get public bundle "
"for device {device_id}").format(node=node,