Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for server templates #1218

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

UiP9AV6Y
Copy link

instead of sending title/message templates as part of the publishing request, systems can simply reference existing templates from the server. this has two advantages
a) publish URLs become shorter
b) publish URLs become easier to reuse

the changes backwards-compatible, as the tpl parameter continues to support truthy boolean values.
the feature has to be enabled on the server. available templates and their content are exposed via new API endpoints.

instead of sending title/message templates as part of the publishing
request, systems can simply reference existing templates from the server.
this has two advantages
a) publish URLs become shorter
b) publish URLs become easier to reuse

the changes backwards-compatible, as the `tpl` parameter continues
to support truthy boolean values.
the feature has to be enabled on the server. available templates
and their content are exposed via new API endpoints.
@wunter8
Copy link
Contributor

wunter8 commented Nov 11, 2024

Wow! Thanks for working on this! Having message templates on the server is one of the features we talked about in the past, but obviously we haven't implemented it yet.

Binwiederhier will be the one to decide whether to merge this, but here are some of my thoughts:

  1. It's great that this is backwards-compatible
  2. I don't love that the feature is all or nothing: title and message both online or both server templates. I'm thinking mostly for titles, which are typically short and might not even depend on the contents of the JSON body. For example, having to create a file on the server just to have a title with "New Grafana Alert" (or any other fixed string) would be unfortunate.

I don't know the best way to remedy this, though. I considered something like tpl=server,inline for a server message and inline title. Or tpl=1&message=server:grafana&title=New+Grafana+Alert. Looking toward the future, though, we have discussed making it possible to template all message fields (such as priority and tags) based on the JSON body. I don't know what that looks like and how it combines with this.

  1. I don't use Golang very much. I saw some different styles between your code and the existing ntfy code. Not sure which is better 🤷‍♂️
  2. You seemed to do a good job adding additional tests while keeping the existing template tests 👍
  3. Thanks for keeping security concerns in mind like path traversals!

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.

2 participants