Skip to content

Respect X-Persist header to skip saving messages to local history#178

Open
EugeneShtoka wants to merge 10 commits into
binwiederhier:mainfrom
EugeneShtoka:x-persist-header
Open

Respect X-Persist header to skip saving messages to local history#178
EugeneShtoka wants to merge 10 commits into
binwiederhier:mainfrom
EugeneShtoka:x-persist-header

Conversation

@EugeneShtoka

Copy link
Copy Markdown

Summary

When the server sends "persist": false in the message payload (published with X-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 — add persist: Boolean? field mapped from server JSON
  • Database.kt — add @Ignore val persist: Boolean = true to Notification (same pattern as existing event field — in-memory only, not stored in DB)
  • NotificationParser.kt — populate persist from message.persist
  • Repository.kt — skip notificationDao.add() when notification.persist == false; still updates lastNotificationId and returns true so the notification popup is dispatched normally

Related

Server-side support: binwiederhier/ntfy#1725

EugeneShtoka and others added 10 commits May 4, 2026 15:00
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant