Skip to content

Commit

Permalink
feat(alerting): add option to disable message caching in ntfy provider
Browse files Browse the repository at this point in the history
  • Loading branch information
stendler committed Jun 2, 2024
1 parent 7e69191 commit 8fac111
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) | `nil` |
| `alerting.ntfy.cache` | Whether message should be cached server side. [ntfy.sh defaults to true](https://docs.ntfy.sh/publish/#message-caching) | `nil` |
| `alerting.ntfy.default-alert` | Default alert configuration. <br />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
Expand Down
4 changes: 4 additions & 0 deletions alerting/provider/ntfy/ntfy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8fac111

Please sign in to comment.