[PR #1725] Add X-Persist header to control client-side local storage #1704

Open
opened 2026-05-07 01:03:18 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/1725
Author: @EugeneShtoka
Created: 5/4/2026
Status: 🔄 Open

Base: mainHead: x-persist-header


📝 Commits (1)

  • 434ebbf Add X-Persist header to control client-side local storage

📊 Changes

3 files changed (+12 additions, -0 deletions)

View changed files

📝 model/model.go (+1 -0)
📝 server/server.go (+1 -0)
📝 server/util.go (+10 -0)

📄 Description

Summary

Introduces a new X-Persist (or Persist) publish parameter. When set to no, the server includes "persist": false in the broadcast JSON payload, signalling clients that they should not save the message to local history.

This is intentionally separate from X-Cache (server-side caching) so that publishers can control client persistence independently:

  • X-Cache: no — server does not cache the message
  • X-Persist: no — clients should not save the message to local history

A common use case is ephemeral clipboard sync or other transient notifications that should be delivered and shown, but not accumulate in message history.

Changes

  • model/model.go — add Persist *bool field to Message (omitted from JSON when nil)
  • server/util.go — add readOptionalBoolParam helper returning *bool (nil when not set)
  • server/server.go — parse x-persist/persist header and set m.Persist

Android client support: EugeneShtoka/ntfy-android#1 (respects "persist": false to skip local DB insert)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/1725 **Author:** [@EugeneShtoka](https://github.com/EugeneShtoka) **Created:** 5/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `x-persist-header` --- ### 📝 Commits (1) - [`434ebbf`](https://github.com/binwiederhier/ntfy/commit/434ebbf178d234d9f0efe02a220001cc6e38d071) Add X-Persist header to control client-side local storage ### 📊 Changes **3 files changed** (+12 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `model/model.go` (+1 -0) 📝 `server/server.go` (+1 -0) 📝 `server/util.go` (+10 -0) </details> ### 📄 Description ## Summary Introduces a new `X-Persist` (or `Persist`) publish parameter. When set to `no`, the server includes `"persist": false` in the broadcast JSON payload, signalling clients that they should not save the message to local history. This is intentionally **separate from `X-Cache`** (server-side caching) so that publishers can control client persistence independently: - `X-Cache: no` — server does not cache the message - `X-Persist: no` — clients should not save the message to local history A common use case is ephemeral clipboard sync or other transient notifications that should be delivered and shown, but not accumulate in message history. ## Changes - `model/model.go` — add `Persist *bool` field to `Message` (omitted from JSON when nil) - `server/util.go` — add `readOptionalBoolParam` helper returning `*bool` (nil when not set) - `server/server.go` — parse `x-persist`/`persist` header and set `m.Persist` ## Related Android client support: EugeneShtoka/ntfy-android#1 (respects `"persist": false` to skip local DB insert) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1704
No description provided.