Only call should_heartbeat if auto_heartbeat is enabled

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2022-03-01 22:47:12 +01:00
parent f1750d6df3
commit c936703941
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -720,9 +720,11 @@ class XEP_0384(BasePlugin):
finally: finally:
asyncio.ensure_future(self._publish_bundle()) asyncio.ensure_future(self._publish_bundle())
if self.auto_heartbeat:
log.debug('Checking if heartbeat is required. auto_hearbeat enabled.')
should_heartbeat = await self._should_heartbeat(sender, isPrekeyMessage) should_heartbeat = await self._should_heartbeat(sender, isPrekeyMessage)
if self.auto_heartbeat and should_heartbeat: if should_heartbeat:
log.debug('Decryption: Sending hearbeat to JID: %r', jid) log.debug('Decryption: Sending hearbeat to JID %r', jid, device)
async def send_heartbeat(): async def send_heartbeat():
log.debug('Sending a heartbeat message') log.debug('Sending a heartbeat message')
msg = await self.make_heartbeat(JID(jid)) msg = await self.make_heartbeat(JID(jid))