put property name back as originator and recipients

This commit is contained in:
cemturker
2020-11-25 00:30:23 +01:00
parent c5e2b0f159
commit 199f14667e
4 changed files with 22 additions and 22 deletions

View File

@ -14,14 +14,14 @@ const (
// AlertProvider is the configuration necessary for sending an alert using Messagebird
type AlertProvider struct {
AccessKey string `yaml:"access-key"`
From string `yaml:"from"`
To string `yaml:"to"`
AccessKey string `yaml:"access-key"`
Originator string `yaml:"originator"`
Recipients string `yaml:"recipients"`
}
// IsValid returns whether the provider's configuration is valid
func (provider *AlertProvider) IsValid() bool {
return len(provider.AccessKey) > 0 && len(provider.From) > 0 && len(provider.To) > 0
return len(provider.AccessKey) > 0 && len(provider.Originator) > 0 && len(provider.Recipients) > 0
}
// ToCustomAlertProvider converts the provider into a custom.AlertProvider
@ -41,7 +41,7 @@ func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, aler
"originator": "%s",
"recipients": "%s",
"body": "%s"
}`, provider.From, provider.To, message),
}`, provider.Originator, provider.Recipients, message),
Headers: map[string]string{
"Content-Type": "application/json",
"Authorization": fmt.Sprintf("AccessKey %s", provider.AccessKey),

View File

@ -13,9 +13,9 @@ func TestMessagebirdAlertProvider_IsValid(t *testing.T) {
t.Error("provider shouldn't have been valid")
}
validProvider := AlertProvider{
AccessKey: "1",
From: "1",
To: "1",
AccessKey: "1",
Originator: "1",
Recipients: "1",
}
if !validProvider.IsValid() {
t.Error("provider should've been valid")
@ -24,9 +24,9 @@ func TestMessagebirdAlertProvider_IsValid(t *testing.T) {
func TestAlertProvider_ToCustomAlertProviderWithResolvedAlert(t *testing.T) {
provider := AlertProvider{
AccessKey: "1",
From: "1",
To: "1",
AccessKey: "1",
Originator: "1",
Recipients: "1",
}
customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, true)
if customAlertProvider == nil {
@ -39,9 +39,9 @@ func TestAlertProvider_ToCustomAlertProviderWithResolvedAlert(t *testing.T) {
func TestAlertProvider_ToCustomAlertProviderWithTriggeredAlert(t *testing.T) {
provider := AlertProvider{
AccessKey: "1",
From: "1",
To: "1",
AccessKey: "1",
Originator: "1",
Recipients: "1",
}
customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &core.Alert{}, &core.Result{}, false)
if customAlertProvider == nil {