From 71c592d6663d7fa376063dad35277c829292cc24 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 12:55:41 +0100 Subject: [PATCH] xep_0384: Move _fetching_bundle method out of plugin class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugin.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index a9edf1a..64d8dda 100644 --- a/plugin.py +++ b/plugin.py @@ -98,6 +98,10 @@ def _generate_encrypted_payload(encrypted) -> Encrypted: return tag +def _fetching_bundle(self, jid: str, exn: Exception, key: str, _val: Any) -> bool: + return isinstance(exn, omemo.exceptions.MissingBundleException) and key == jid + + # XXX: This should probably be moved in plugins/base.py? class PluginCouldNotLoad(Exception): pass @@ -314,9 +318,6 @@ class XEP_0384(BasePlugin): finally: asyncio.ensure_future(self._publish_bundle()) - def _fetching_bundle(self, jid: str, exn: Exception, key: str, _val: Any) -> bool: - return isinstance(exn, omemo.exceptions.MissingBundleException) and key == jid - async def encrypt_message(self, plaintext: str, recipients: List[JID]) -> Encrypted: """ Returns an encrypted payload to be placed into a message. @@ -371,7 +372,7 @@ class XEP_0384(BasePlugin): # do OMEMO, or hasn't published any device list for any # other reason. - if any(self._fetching_bundle(key, *err) for err in errors): + if any(_fetching_bundle(key, *err) for err in errors): continue no_eligible_devices.add(key)