diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index fd0586c..2e74900 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -179,6 +179,9 @@ class XEP_0384(BasePlugin): backend_loaded = HAS_OMEMO + # OMEMO Bundles used for encryption + bundles = {} # type: Dict[str, Dict[int, ExtendedPublicBundle]] + def plugin_init(self) -> None: if not self.backend_loaded: log.info("xep_0384 cannot be loaded as the backend omemo library " @@ -441,7 +444,6 @@ class XEP_0384(BasePlugin): """ recipients = [jid.bare for jid in recipients] - bundles = {} # type: Dict[str, Dict[int, ExtendedPublicBundle]] old_errors = None # type: Optional[List[Tuple[Exception, Any, Any]]] while True: @@ -456,7 +458,7 @@ class XEP_0384(BasePlugin): encrypted = self._omemo.encryptMessage( recipients, plaintext.encode('utf-8'), - bundles, + self.bundles, expect_problems=expect_problems, ) return _generate_encrypted_payload(encrypted) @@ -474,7 +476,7 @@ class XEP_0384(BasePlugin): elif isinstance(exn, omemo.exceptions.MissingBundleException): bundle = await self._fetch_bundle(exn.bare_jid, exn.device) if bundle is not None: - devices = bundles.setdefault(exn.bare_jid, {}) + devices = self.bundles.setdefault(exn.bare_jid, {}) devices[exn.device] = bundle elif isinstance(exn, omemo.exceptions.TrustException): # On TrustException, there are two possibilities.