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 <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-03-19 17:51:16 -07:00
parent c00214e408
commit 265a9976cf

View File

@@ -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, "> * <@") {