From 265a9976cfd20ee97056151eadc9987863e208cd Mon Sep 17 00:00:00 2001 From: prosolis <5590409+prosolis@users.noreply.github.com> Date: Thu, 19 Mar 2026 17:51:16 -0700 Subject: [PATCH] Ignore message edits to prevent duplicate URL previews and stat inflation Matrix edits arrive as m.room.message with m.replace relation. Without filtering these out, each edit was re-triggering URL previews and incrementing user stats as if it were a new message. Co-Authored-By: Claude Opus 4.6 --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 8c15e74..5f91558 100644 --- a/main.go +++ b/main.go @@ -203,6 +203,12 @@ func main() { return } + // Ignore edits — they arrive as m.room.message with m.replace relation. + // Without this check, edits re-trigger URL previews and inflate stats. + if content.RelatesTo != nil && content.RelatesTo.Type == event.RelReplace { + return + } + body := content.Body // Strip Matrix reply fallback: "> <@user:server> ..." lines followed by blank line if strings.HasPrefix(body, "> <@") || strings.HasPrefix(body, "> * <@") {