From e893e6aeec495cd4eeba1ebb70b3d4004bc917b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 27 Aug 2019 23:43:04 +0200 Subject: [PATCH] Change decrypt_message API. Don't take the entire message anymore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp_omemo/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index 2f901b3..1bf170b 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -414,11 +414,16 @@ class XEP_0384(BasePlugin): def is_encrypted(self, msg: Message) -> bool: return msg.xml.find('{%s}encrypted' % OMEMO_BASE_NS) is not None - def decrypt_message(self, msg: Message, allow_untrusted: bool = False) -> Optional[str]: - header = msg['omemo_encrypted']['header'] - payload = b64dec(msg['omemo_encrypted']['payload']['value']) + def decrypt_message( + self, + encrypted: Encrypted, + sender: JID, + allow_untrusted: bool = False, + ) -> Optional[str]: + header = encrypted['header'] + payload = b64dec(encrypted['payload']['value']) - jid = msg['from'].bare + jid = sender sid = int(header['sid']) key = header.xml.find("{%s}key[@rid='%s']" % (