Skip to content

Commit

Permalink
pushover backend: allow user to set API key (Fixes: hrntknr#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsekman committed Aug 28, 2024
1 parent d52a786 commit 9fc99d9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions backends/pushover.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ const PUSHOVER_API_TOKEN = "abughxjjtuofgt89bz21mibut67j5t"
const PUSHOVER_API_URL = "https://api.pushover.net/1/messages.json"

type PushoverConfig struct {
UserKey string `mapstructure:"user_key" validate:"required"`
Device *string `mapstructure:"device" validate:"omitempty"`
Priority *string `mapstructure:"priority" validate:"omitempty,oneof=emergency high normal low lowest"`
Retry *int `mapstructure:"retry" validate:"omitempty,min=30"`
Expire *int `mapstructure:"expire" validate:"omitempty,min=0,max=10800"`
UserKey string `mapstructure:"user_key" validate:"required"`
ApplicationKey string `mapstructure:"application_key"`
Device *string `mapstructure:"device" validate:"omitempty"`
Priority *string `mapstructure:"priority" validate:"omitempty,oneof=emergency high normal low lowest"`
Retry *int `mapstructure:"retry" validate:"omitempty,min=30"`
Expire *int `mapstructure:"expire" validate:"omitempty,min=0,max=10800"`
}

type Pushover struct {
Expand All @@ -45,6 +46,9 @@ func (*Pushover) Send(configIface interface{}, title string, message string, sta
"title": title,
"message": message,
}
if config.ApplicationKey != "" {
body["token"] = *&config.ApplicationKey
}
if config.Device != nil {
body["device"] = *config.Device
}
Expand Down

0 comments on commit 9fc99d9

Please sign in to comment.