Respect X-Persist header to skip saving messages to local history#178
Open
EugeneShtoka wants to merge 10 commits into
Open
Respect X-Persist header to skip saving messages to local history#178EugeneShtoka wants to merge 10 commits into
EugeneShtoka wants to merge 10 commits into
Conversation
When the server sends "persist": false in the message payload (set via the X-Persist: no publish header), the Android client skips inserting the notification into the local Room database. The notification is still delivered and shown as a popup, but will not appear in the app's message history. The persist field follows the same @ignore pattern as the existing event field — it is an in-memory-only attribute, not stored in the database. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the server sends
"persist": falsein the message payload (published withX-Persist: no), the Android client skips inserting the notification into the local Room database. The notification is still delivered and shown as a popup, but will not appear in the app's message history.This is useful for ephemeral notifications (e.g. clipboard sync) that should be delivered but not accumulate in local history.
Changes
Message.kt— addpersist: Boolean?field mapped from server JSONDatabase.kt— add@Ignore val persist: Boolean = truetoNotification(same pattern as existingeventfield — in-memory only, not stored in DB)NotificationParser.kt— populatepersistfrommessage.persistRepository.kt— skipnotificationDao.add()whennotification.persist == false; still updateslastNotificationIdand returnstrueso the notification popup is dispatched normallyRelated
Server-side support: binwiederhier/ntfy#1725