From cea515aefd04783b5ad03e5b5ce290aa7e8be8b3 Mon Sep 17 00:00:00 2001 From: stendler Date: Sun, 2 Jun 2024 22:20:39 +0200 Subject: [PATCH] feat(alerting): add option to disable message caching in ntfy provider https://docs.ntfy.sh/publish/#message-caching --- README.md | 1 + alerting/provider/ntfy/ntfy.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index d23d39340..800379918 100644 --- a/README.md +++ b/README.md @@ -953,6 +953,7 @@ endpoints: | `alerting.ntfy.click` | Website opened when notification is clicked | `""` | | `alerting.ntfy.priority` | The priority of the alert | `3` | | `alerting.ntfy.firebase` | Whether messages should be delivered via firebase. [ntfy.sh defaults to true](https://docs.ntfy.sh/publish/#disable-firebase) | `""` | +| `alerting.ntfy.cache` | Whether message should be cached server side. [ntfy.sh defaults to true](https://docs.ntfy.sh/publish/#message-caching) | `""` | | `alerting.ntfy.default-alert` | Default alert configuration.
See [Setting a default alert](#setting-a-default-alert) | N/A | [ntfy](https://github.com/binwiederhier/ntfy) is an amazing project that allows you to subscribe to desktop diff --git a/alerting/provider/ntfy/ntfy.go b/alerting/provider/ntfy/ntfy.go index 25c3c9c0a..9c561c36a 100644 --- a/alerting/provider/ntfy/ntfy.go +++ b/alerting/provider/ntfy/ntfy.go @@ -28,6 +28,7 @@ type AlertProvider struct { Email string `yaml:"email,omitempty"` // Defaults to "" Click string `yaml:"click,omitempty"` // Defaults to "" Firebase *bool `yaml:"firebase,omitempty"` // Defaults to nil + Cache *bool `yaml:"cache,omitempty"` // Defaults to nil // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` @@ -62,6 +63,9 @@ func (provider *AlertProvider) Send(ep *endpoint.Endpoint, alert *alert.Alert, r if provider.Firebase != nil && !*provider.Firebase { request.Header.Set("Firebase", "no") } + if provider.Cache != nil && !*provider.Cache { + request.Header.Set("Cache", "no") + } response, err := client.GetHTTPClient(nil).Do(request) if err != nil { return err