Add interface semi-hidden to RatchetForwardingMessage
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
26665d9e6a
commit
494899bb3c
1 changed files with 19 additions and 15 deletions
|
@ -602,10 +602,11 @@ class XEP_0384(BasePlugin):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
msg = self.xmpp.make_message(mto=jid)
|
msg = self.xmpp.make_message(mto=jid)
|
||||||
encrypted = await self.encrypt_key_transport_message(
|
encrypted = await self.encrypt_message(
|
||||||
plaintext=None,
|
plaintext=None,
|
||||||
recipients=[jid],
|
recipients=[jid],
|
||||||
expect_problems=None,
|
expect_problems=None,
|
||||||
|
_ignore_trust=True,
|
||||||
)
|
)
|
||||||
msg.append(encrypted)
|
msg.append(encrypted)
|
||||||
return msg
|
return msg
|
||||||
|
@ -708,21 +709,10 @@ class XEP_0384(BasePlugin):
|
||||||
|
|
||||||
async def encrypt_message(
|
async def encrypt_message(
|
||||||
self,
|
self,
|
||||||
plaintext: str,
|
plaintext: Optional[str],
|
||||||
recipients: List[JID],
|
|
||||||
expect_problems: Optional[Dict[JID, List[int]]] = None,
|
|
||||||
) -> Encrypted:
|
|
||||||
return await self.encrypt_key_transport_message(
|
|
||||||
plaintext.encode('utf-8'),
|
|
||||||
recipients,
|
|
||||||
expect_problems,
|
|
||||||
)
|
|
||||||
|
|
||||||
async def encrypt_key_transport_message(
|
|
||||||
self,
|
|
||||||
plaintext: Optional[bytes],
|
|
||||||
recipients: List[JID],
|
recipients: List[JID],
|
||||||
expect_problems: Optional[Dict[JID, List[int]]] = None,
|
expect_problems: Optional[Dict[JID, List[int]]] = None,
|
||||||
|
_ignore_trust: bool = False,
|
||||||
) -> Encrypted:
|
) -> Encrypted:
|
||||||
"""
|
"""
|
||||||
Returns an encrypted payload to be placed into a message.
|
Returns an encrypted payload to be placed into a message.
|
||||||
|
@ -730,6 +720,14 @@ class XEP_0384(BasePlugin):
|
||||||
The API for getting an encrypted payload consists of trying first
|
The API for getting an encrypted payload consists of trying first
|
||||||
and fixing errors progressively. The actual sending happens once the
|
and fixing errors progressively. The actual sending happens once the
|
||||||
application (us) thinks we're good to go.
|
application (us) thinks we're good to go.
|
||||||
|
|
||||||
|
If `plaintext` is specified, this will generate a full OMEMO payload. If
|
||||||
|
not, if `_ignore_trust` is True, this will generate a ratchet forwarding
|
||||||
|
message, and otherwise it will generate a key transport message.
|
||||||
|
|
||||||
|
These are rather technical details to the user and fiddling with
|
||||||
|
parameters else than `plaintext` and `recipients` should be rarely
|
||||||
|
needed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
recipients = [jid.bare for jid in recipients]
|
recipients = [jid.bare for jid in recipients]
|
||||||
|
@ -749,7 +747,13 @@ class XEP_0384(BasePlugin):
|
||||||
if plaintext is not None:
|
if plaintext is not None:
|
||||||
encrypted = self._omemo.encryptMessage(
|
encrypted = self._omemo.encryptMessage(
|
||||||
recipients,
|
recipients,
|
||||||
plaintext,
|
plaintext.encode('utf-8'),
|
||||||
|
self.bundles,
|
||||||
|
expect_problems=expect_problems,
|
||||||
|
)
|
||||||
|
elif _ignore_trust:
|
||||||
|
encrypted = self._omemo.encryptRatchetForwardingMessage(
|
||||||
|
recipients,
|
||||||
self.bundles,
|
self.bundles,
|
||||||
expect_problems=expect_problems,
|
expect_problems=expect_problems,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue