From fef03ddec0c637815b7c4193769ebdfff7700e3a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 12 Oct 2022 22:09:23 +0300 Subject: [PATCH] Maybe actually fix time comparison --- mautrix_telegram/user.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mautrix_telegram/user.py b/mautrix_telegram/user.py index 2e7194d3..0df77ef0 100644 --- a/mautrix_telegram/user.py +++ b/mautrix_telegram/user.py @@ -695,12 +695,12 @@ class User(DBUser, AbstractUser, BaseUser): self.log.exception(f"Error while creating {portal.tgid_log}") if portal.mxid and puppet and puppet.is_real_user: tg_space = portal.tgid if portal.peer_type == "channel" else self.tgid - last_message_date: datetime = cast(datetime, dialog.date) + last_message_date: float = cast(datetime, dialog.date).timestamp() unread_threshold_hours = self.config["bridge.backfill.unread_hours_threshold"] force_read = ( was_created and unread_threshold_hours >= 0 - and last_message_date + timedelta(hours=unread_threshold_hours) < datetime.utcnow() + and last_message_date + (unread_threshold_hours * 60 * 60) < time.time() ) if dialog.unread_count == 0 or force_read: # This is usually more reliable than finding a specific message @@ -709,7 +709,7 @@ class User(DBUser, AbstractUser, BaseUser): if force_read: self.log.debug( f"Marking {portal.tgid_log} as read because the last message is from " - f"{last_message_date} (unread threshold is {unread_threshold_hours} hours)" + f"{dialog.date} (unread threshold is {unread_threshold_hours} hours)" ) else: last_read = await DBMessage.get_one_by_tgid(