Keep track of known bundles on the instance
Since we're raising exceptions often to yield to the client, we need to keep track of bundles on the object and not just in the method itself. Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
869b11d322
commit
2a346ac48d
1 changed files with 5 additions and 3 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue