Above all, I do not want to receive another notification if nothing has changed in the post that would cause a notification. Correcting a typo should not notify me if I have already been notified just because 2 notifications about the same topic were collapsed before. And I never noticed that for years until it happened in December.
I asked ChatGPT to write a summary of what it told me about this issue, when I tried to find repro steps based on the code
Summary: Why duplicate notifications are normally prevented, and why it fails here AI
Core issue
Duplicate-prevention relies on finding a reply notification that is still scoped to the edited post, but reply notifications are collapsed, destroyed, or re-attached to a different post.
As a result, edit-time suppression cannot reliably detect that the user was already notified about the reply.
Duplicate notifications are prevented in PostAlerter by:
- Tracking users already notified during post creation
notified = []
- Suppressing secondary triggers if a reply notification exists
if [:quoted, :linked, :mentioned, :chat_quoted].include?(type)
return if existing_notifications.find { |n|
n.notification_type == Notification.types[:replied]
}
end
This is meant to avoid notifying a user twice about the same post.
- Collapsing reply notifications
Reply notifications (:replied) are collapsed per topic:
destroy_notifications(user, COLLAPSED_NOTIFICATION_TYPES, topic)
The surviving notification is re-attached to:
post = first_unread_post(user, topic)
so the notification no longer represents the post that originally triggered it. As a result, suppression logic that relies on matching post_number cannot reliably detect prior notifications for edited posts.
Why this fails in the repro case
In the repro:
- The user is notified about the reply initially
- When multiple replies exist, reply notifications are collapsed
- The collapsed notification:
- may no longer exist for the edited post, or
- exists with a different
post_number
- On edit:
- reply logic does not run (
new_record == false) - suppression checks only for a post-scoped
:repliednotification - none is found → suppression fails
- reply logic does not run (
- Quote/link detection runs again and creates new notifications
From the user’s perspective:
“I was already notified about this reply.”
From the code’s perspective:
“There is no existing notification for this post.”
Both are true.