1
0
Fork 0

fix: check that oldest_message_id is not None in MUC.backfill()

does not seem to trigger any issue but mypy does not like it

also, paint it newer black
This commit is contained in:
nicoco 2024-02-29 21:39:18 +01:00
parent 59957fd436
commit d32f1f0a9e
1 changed files with 12 additions and 7 deletions

View File

@ -66,17 +66,22 @@ class MUC(LegacyMUC[str, str, Participant, str]):
"""
Request history for messages older than the oldest message given by ID and date.
"""
if oldest_message_id not in self.session.muc_sent_msg_ids:
if (
oldest_message_id is not None
and oldest_message_id not in self.session.muc_sent_msg_ids
):
# WhatsApp requires a full reference to the last seen message in performing on-demand sync.
return
oldest_message = whatsapp.Message(
ID=oldest_message_id or "",
IsCarbon=self.session.message_is_carbon(self, oldest_message_id)
if oldest_message_id
else False,
Timestamp=int(oldest_message_date.timestamp())
if oldest_message_date
else 0,
IsCarbon=(
self.session.message_is_carbon(self, oldest_message_id)
if oldest_message_id
else False
),
Timestamp=(
int(oldest_message_date.timestamp()) if oldest_message_date else 0
),
)
self.session.whatsapp.RequestMessageHistory(self.legacy_id, oldest_message)