Skip to content

fix: Duplicated notifications#446

Merged
jmattheis merged 1 commit intogotify:masterfrom
axllent:duplicates
Apr 26, 2026
Merged

fix: Duplicated notifications#446
jmattheis merged 1 commit intogotify:masterfrom
axllent:duplicates

Conversation

@axllent
Copy link
Copy Markdown

@axllent axllent commented Apr 24, 2026

Hopefully this is a fix for #242 which has been around since 2022. I still experience this frequently, so (as much as I hate to admit it) I asked Claude and this is what it came back with. I don't do Java at all - but it seemed to be pretty confident this was the issue. Maybe worth a shot to see if it finally resolves the issue, and hopefully makes more sense to you than me?

The race condition: When the user opens the app via a notification, two things happen near-simultaneously:

  1. onResume() registers the broadcast receiver and launches updateMissedMessages(), which fetches missed messages from the server via HTTP
  2. The WebSocket reconnects (common when the phone was sleeping/offline) and calls notifyMissedNotifications(), which re-broadcasts those same missed messages — which the now-registered receiver picks up and adds via addSingleMessage()

Both paths call addMessages()newMessage()addMessage() for the same set of messages. Since there was no duplicate guard, each message got inserted twice.

The fix adds an id-based existence check before inserting into either list (ALL_MESSAGES or the app-specific list), so the second insertion of any already-present message is silently skipped.

@jmattheis
Copy link
Copy Markdown
Member

Thanks for the contribution I've rewritten the fix. Both the broadcast receiver and missing message sending use the newMessage method, and this method now should skip messages that where already processed.

@jmattheis jmattheis merged commit d6cd95a into gotify:master Apr 26, 2026
2 checks passed
@axllent
Copy link
Copy Markdown
Author

axllent commented Apr 26, 2026

Awesome, let's hope it resolves those pesky duplications once and for all 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants