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 missing ttl in pushhover #3474

Merged
merged 5 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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