Fixing Pushover issue with message length

thanks to Merovius
This commit is contained in:
Johannes Visintini 2016-04-16 13:00:46 +02:00
parent 9136cf8f00
commit f38a16c848
1 changed files with 5 additions and 1 deletions

View File

@ -752,8 +752,12 @@ func (n *Pushover) Notify(ctx context.Context, as ...*types.Alert) error {
title := tmpl(n.conf.Title) title := tmpl(n.conf.Title)
message := tmpl(n.conf.Message) message := tmpl(n.conf.Message)
parameters.Add("title", title) parameters.Add("title", title)
if len(title) > 512 {
title = title[:512]
log.With("incident", key).Debugf("Truncated title to %q due to Pushover message limit", title)
}
if len(title)+len(message) > 512 { if len(title)+len(message) > 512 {
message = message[:512] message = message[:512-len(title)]
log.With("incident", key).Debugf("Truncated message to %q due to Pushover message limit", message) log.With("incident", key).Debugf("Truncated message to %q due to Pushover message limit", message)
} }
if message == "" { if message == "" {