Skip to content

Commit

Permalink
Add missing ttl in pushhover (#3474)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Hélia Barroso <[email protected]>
Signed-off-by: Simon Pasquier <[email protected]>
Co-authored-by: Simon Pasquier <[email protected]>
  • Loading branch information
heliapb and simonpasquier authored Aug 31, 2023
1 parent 6cbe2eb commit ba30364
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ type PushoverConfig struct {
Priority string `yaml:"priority,omitempty" json:"priority,omitempty"`
Retry duration `yaml:"retry,omitempty" json:"retry,omitempty"`
Expire duration `yaml:"expire,omitempty" json:"expire,omitempty"`
TTL duration `yaml:"ttl,omitempty" json:"ttl,omitempty"`
HTML bool `yaml:"html" json:"html,omitempty"`
}

Expand Down
3 changes: 3 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,9 @@ token_file: <filepath>
# acknowledges the notification.
[ expire: <duration> | default = 1h ]
# Optional time to live (TTL) to use for notification, see https://pushover.net/api#ttl
[ ttl: <duration> ]
# The HTTP client's configuration.
[ http_config: <http_config> | default = global.http_config ]
```
Expand Down
6 changes: 6 additions & 0 deletions notify/pushover/pushover.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
parameters.Add("expire", fmt.Sprintf("%d", int64(time.Duration(n.conf.Expire).Seconds())))
parameters.Add("device", tmpl(n.conf.Device))
parameters.Add("sound", tmpl(n.conf.Sound))

newttl := int64(time.Duration(n.conf.TTL).Seconds())
if newttl > 0 {
parameters.Add("ttl", fmt.Sprintf("%d", newttl))
}

if err != nil {
return false, err
}
Expand Down

0 comments on commit ba30364

Please sign in to comment.