Skip to content

Commit 8a542c2

Browse files
committed
feat(altering): Ntfy click link placeholder support
1 parent 15a8055 commit 8a542c2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,10 @@ The JSON payload sent to the n8n webhook will include:
16341634
[ntfy](https://github.com/binwiederhier/ntfy) is an amazing project that allows you to subscribe to desktop
16351635
and mobile notifications, making it an awesome addition to Gatus.
16361636

1637+
The following placeholders are supported in `click`:
1638+
- `[ENDPOINT_URL]` - Resolved from `endpoints[].url`
1639+
- `[ENDPOINT_KEY]` - Resolved from internal endpoint key
1640+
16371641
Example:
16381642
```yaml
16391643
alerting:

alerting/provider/ntfy/ntfy.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ type Body struct {
171171
Click string `json:"click,omitempty"`
172172
}
173173

174+
func resolveEndpointPlaceholders(data string, ep *endpoint.Endpoint) string {
175+
placeholders := map[string]string{
176+
"[ENDPOINT_URL]": ep.URL,
177+
"[ENDPOINT_KEY]": ep.Key(),
178+
}
179+
for placeholder, value := range placeholders {
180+
data = strings.ReplaceAll(data, placeholder, value)
181+
}
182+
return data
183+
}
184+
174185
// buildRequestBody builds the request body for the provider
175186
func (provider *AlertProvider) buildRequestBody(cfg *Config, ep *endpoint.Endpoint, alert *alert.Alert, result *endpoint.Result, resolved bool) []byte {
176187
var message, formattedConditionResults, tag string
@@ -201,7 +212,7 @@ func (provider *AlertProvider) buildRequestBody(cfg *Config, ep *endpoint.Endpoi
201212
Tags: []string{tag},
202213
Priority: cfg.Priority,
203214
Email: cfg.Email,
204-
Click: cfg.Click,
215+
Click: resolveEndpointPlaceholders(cfg.Click, ep),
205216
})
206217
return body
207218
}

0 commit comments

Comments
 (0)