From 914e4ea280bb9901c32d94ab0648727201a9d2ff Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 23 Mar 2024 01:46:57 +0200 Subject: [PATCH] Ignore read receipts pointing at old messages --- user.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/user.go b/user.go index a672874..4371e2d 100644 --- a/user.go +++ b/user.go @@ -1173,8 +1173,11 @@ func (user *User) markSelfReadFull(ctx context.Context, portal *Portal, lastMess return } lastMessage, err := user.bridge.DB.Message.GetByID(ctx, portal.Receiver, lastMessageID) - if err == nil && lastMessage == nil || lastMessage.IsFakeMXID() { + if err == nil && (lastMessage == nil || lastMessage.IsFakeMXID()) { lastMessage, err = user.bridge.DB.Message.GetLastInChatWithMXID(ctx, portal.Key) + if idToInt(lastMessage.ID) > idToInt(lastMessageID) { + return + } } if err != nil { user.zlog.Warn().Err(err).Msg("Failed to get last message in chat to mark it as read")