From f81e6525cd77e486c1b528471b90e263c3a16dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 1 Dec 2018 18:36:17 +0000 Subject: [PATCH] xep_0384: import omemo.exceptions directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugin.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index 8e8a634..16223c6 100644 --- a/plugin.py +++ b/plugin.py @@ -26,7 +26,7 @@ log = logging.getLogger(__name__) HAS_OMEMO = True try: - from omemo.exceptions import MissingBundleException, NoEligibleDevicesException + import omemo.exceptions from omemo import SessionManager, ExtendedPublicBundle from omemo.util import generateDeviceID from omemo.backends import Backend @@ -304,7 +304,7 @@ class XEP_0384(BasePlugin): return body def _fetching_bundle(self, jid: str, exn: Exception, key: str, _val: Any) -> bool: - return isinstance(exn, MissingBundleException) and key == jid + return isinstance(exn, omemo.exceptions.MissingBundleException) and key == jid async def encrypt_message(self, plaintext: str, recipients: List[JID]) -> Encrypted: """ @@ -343,12 +343,12 @@ class XEP_0384(BasePlugin): no_eligible_devices = set() # type: Set[str] for (exn, key, val) in errors: - if isinstance(exn, MissingBundleException): + if isinstance(exn, omemo.exceptions.MissingBundleException): bundle = await self._fetch_bundle(key, val) if bundle is not None: devices = bundles.setdefault(key, {}) devices[val] = bundle - elif isinstance(exn, NoEligibleDevicesException): + elif isinstance(exn, omemo.exceptions.NoEligibleDevicesException): # This error is apparently returned every time the omemo # lib couldn't find a device to encrypt to for a # particular JID.