[PR #1057] [CLOSED] add templating for title and message fields #1504

Closed
opened 2026-05-07 01:02:24 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/1057
Author: @wunter8
Created: 3/18/2024
Status: Closed

Base: mainHead: templating


📝 Commits (10+)

  • df7d6ba add templating for title and message fields
  • b2eb5b9 use existing message and title fields for templates
  • 867cf28 refactor gjson parsing code
  • 03737db update docs
  • 7fd5f0b allow large HTTP body so long as resulting message is small
  • 83356f5 remove debug print statement
  • 1966f80 Merge branch 'main' into templating
  • de65d07 Simplify(?) templating cases
  • 9247dac Move things, revert naming
  • c81a0f5 Merge pull request #1 from binwiederhier/templating-2

📊 Changes

14 files changed (+312 additions, -60 deletions)

View changed files

📝 cmd/access_test.go (+2 -0)
📝 cmd/config_loader_test.go (+1 -0)
📝 cmd/publish_test.go (+3 -0)
📝 docs/publish.md (+28 -0)
📝 docs/releases.md (+6 -0)
📝 go.mod (+3 -0)
📝 go.sum (+7 -22)
📝 server/errors.go (+2 -0)
📝 server/server.go (+66 -29)
📝 server/server_admin.go (+5 -4)
📝 server/server_test.go (+182 -0)
📝 server/util.go (+3 -2)
📝 test/server.go (+1 -1)
📝 util/peek.go (+3 -2)

📄 Description

Here's an initial working implementation, based on https://github.com/binwiederhier/ntfy/pull/171.

Right now, only the message and title fields can be templated, each using their own header (since this seemed like the quickest way to get something working).

In a future iteration, I think allowing other fields to be templated (e.g., priority, actions, attachment url, topic?, etc.) would be cool.

In that version, I was imagining an X-Template header that includes probably a JSON string for the different fields of a message (e.g., {"message":"${field.value} is ${field2}", "title":"An error occurred on ${hostname}", "priority":${error.level}, "attachment":"${error.screenshot.url}"})


🔄 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/1057 **Author:** [@wunter8](https://github.com/wunter8) **Created:** 3/18/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `templating` --- ### 📝 Commits (10+) - [`df7d6ba`](https://github.com/binwiederhier/ntfy/commit/df7d6baec59e17b3ac07b2846d067bc17fb94133) add templating for title and message fields - [`b2eb5b9`](https://github.com/binwiederhier/ntfy/commit/b2eb5b94bdc8efd76516aae9b5db4a10d2360bad) use existing message and title fields for templates - [`867cf28`](https://github.com/binwiederhier/ntfy/commit/867cf2808068fd50678b6588f8780497afb88a83) refactor gjson parsing code - [`03737db`](https://github.com/binwiederhier/ntfy/commit/03737dbf5c521a6e87d2f37509822bcf4f853de2) update docs - [`7fd5f0b`](https://github.com/binwiederhier/ntfy/commit/7fd5f0b29d4d0b9cd34bd9d5c1e3759d48a6916b) allow large HTTP body so long as resulting message is small - [`83356f5`](https://github.com/binwiederhier/ntfy/commit/83356f565e5327b2bb20c94530c12e17af2796da) remove debug print statement - [`1966f80`](https://github.com/binwiederhier/ntfy/commit/1966f80855715eca8ec5bf1bdab79e38a68b9398) Merge branch 'main' into templating - [`de65d07`](https://github.com/binwiederhier/ntfy/commit/de65d0751803306d07081f41501688cb0e9b5120) Simplify(?) templating cases - [`9247dac`](https://github.com/binwiederhier/ntfy/commit/9247dac50db7d5a4617079755fde479b50907f80) Move things, revert naming - [`c81a0f5`](https://github.com/binwiederhier/ntfy/commit/c81a0f523ebdee8f4dd8c4eb80631e3ab29c8520) Merge pull request #1 from binwiederhier/templating-2 ### 📊 Changes **14 files changed** (+312 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `cmd/access_test.go` (+2 -0) 📝 `cmd/config_loader_test.go` (+1 -0) 📝 `cmd/publish_test.go` (+3 -0) 📝 `docs/publish.md` (+28 -0) 📝 `docs/releases.md` (+6 -0) 📝 `go.mod` (+3 -0) 📝 `go.sum` (+7 -22) 📝 `server/errors.go` (+2 -0) 📝 `server/server.go` (+66 -29) 📝 `server/server_admin.go` (+5 -4) 📝 `server/server_test.go` (+182 -0) 📝 `server/util.go` (+3 -2) 📝 `test/server.go` (+1 -1) 📝 `util/peek.go` (+3 -2) </details> ### 📄 Description Here's an initial working implementation, based on https://github.com/binwiederhier/ntfy/pull/171. Right now, only the message and title fields can be templated, each using their own header (since this seemed like the quickest way to get something working). In a future iteration, I think allowing other fields to be templated (e.g., priority, actions, attachment url, topic?, etc.) would be cool. In that version, I was imagining an `X-Template` header that includes probably a JSON string for the different fields of a message (e.g., `{"message":"${field.value} is ${field2}", "title":"An error occurred on ${hostname}", "priority":${error.level}, "attachment":"${error.screenshot.url}"}`) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 01:02:24 +02:00
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#1504
No description provided.