diff --git a/slixmpp_omemo/__init__.py b/slixmpp_omemo/__init__.py index 24b5f20..0d21a35 100644 --- a/slixmpp_omemo/__init__.py +++ b/slixmpp_omemo/__init__.py @@ -720,14 +720,16 @@ class XEP_0384(BasePlugin): finally: asyncio.ensure_future(self._publish_bundle()) - should_heartbeat = await self._should_heartbeat(sender, isPrekeyMessage) - if self.auto_heartbeat and should_heartbeat: - log.debug('Decryption: Sending hearbeat to JID: %r', jid) - async def send_heartbeat(): - log.debug('Sending a heartbeat message') - msg = await self.make_heartbeat(JID(jid)) - msg.send() - asyncio.ensure_future(send_heartbeat()) + if self.auto_heartbeat: + log.debug('Checking if heartbeat is required. auto_hearbeat enabled.') + should_heartbeat = await self._should_heartbeat(sender, isPrekeyMessage) + if should_heartbeat: + log.debug('Decryption: Sending hearbeat to JID %r', jid, device) + async def send_heartbeat(): + log.debug('Sending a heartbeat message') + msg = await self.make_heartbeat(JID(jid)) + msg.send() + asyncio.ensure_future(send_heartbeat()) return body