From 09083d0724695b64646172eee5e6655647e809af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 29 Dec 2018 18:57:50 +0100 Subject: [PATCH] xep_0384: handle IqError and IqTimeout in _fetch_bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 64d8dda..9b0552b 100644 --- a/plugin.py +++ b/plugin.py @@ -18,7 +18,7 @@ from slixmpp.plugins.xep_0384.stanza import OMEMO_BASE_NS from slixmpp.plugins.xep_0384.stanza import OMEMO_DEVICES_NS, OMEMO_BUNDLES_NS from slixmpp.plugins.xep_0384.stanza import Bundle, Devices, Device, Encrypted, Key, PreKeyPublic from slixmpp.plugins.base import BasePlugin -from slixmpp.exceptions import IqError +from slixmpp.exceptions import IqError, IqTimeout from slixmpp.stanza import Message, Iq from slixmpp.jid import JID @@ -212,7 +212,10 @@ class XEP_0384(BasePlugin): async def _fetch_bundle(self, jid: str, device_id: int) -> Union[None, ExtendedPublicBundle]: node = '%s:%d' % (OMEMO_BUNDLES_NS, device_id) - iq = await self.xmpp['xep_0060'].get_items(jid, node) + try: + iq = await self.xmpp['xep_0060'].get_items(jid, node) + except (IqError, IqTimeout): + return None bundle = iq['pubsub']['items']['item']['bundle'] return _parse_bundle(self._omemo_backend, bundle)