From 7e079f4260f16c0c07b413e8074a10d59ebea967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 13 Jul 2021 23:48:39 +0200 Subject: [PATCH] make_heartbeat needs to be async 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index 3c2f689..b31d238 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -538,7 +538,7 @@ class XEP_0384(BasePlugin): lengths = map(lambda d_l: d_l[1], receiving_chain_lengths) return max(lengths, default=0) > self.heartbeat_after - def make_heartbeat(self, jid: JID) -> Message: + async def make_heartbeat(self, jid: JID) -> Message: """ Returns a heartbeat message. @@ -548,7 +548,7 @@ class XEP_0384(BasePlugin): """ msg = self.xmpp.make_message(mto=jid) - encrypted = self.encrypt_key_transport_message( + encrypted = await self.encrypt_key_transport_message( plaintext=None, recipients=[jid], expect_problems=None, @@ -644,8 +644,10 @@ class XEP_0384(BasePlugin): asyncio.ensure_future(self._publish_bundle()) if self.auto_heartbeat and self.should_heartbeat(): - msg = self.make_heartbeat(jid) - msg.send() + async def send_heartbeat(): + msg = await self.make_heartbeat(JID(jid)) + msg.send() + asyncio.ensure_future(send_heartbeat()) return body