Skip to content

Commit 8cfd3b4

Browse files
authored
Merge branch 'master' into use_custom_resolver
2 parents 368943f + 3598501 commit 8cfd3b4

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

alerting/provider/gitea/gitea.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (provider *AlertProvider) Send(ep *endpoint.Endpoint, alert *alert.Alert, r
140140
State: gitea.StateOpen,
141141
CreatedBy: cfg.username,
142142
ListOptions: gitea.ListOptions{
143-
Page: 100,
143+
PageSize: 100,
144144
},
145145
},
146146
)
@@ -153,7 +153,7 @@ func (provider *AlertProvider) Send(ep *endpoint.Endpoint, alert *alert.Alert, r
153153
_, _, err = cfg.giteaClient.EditIssue(
154154
cfg.repositoryOwner,
155155
cfg.repositoryName,
156-
issue.ID,
156+
issue.Index,
157157
gitea.EditIssueOption{
158158
State: &stateClosed,
159159
},

alerting/provider/twilio/twilio.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"net/http"
1010
"net/url"
11+
"strings"
1112

1213
"github.com/TwiN/gatus/v5/alerting/alert"
1314
"github.com/TwiN/gatus/v5/client"
@@ -27,6 +28,9 @@ type Config struct {
2728
Token string `yaml:"token"`
2829
From string `yaml:"from"`
2930
To string `yaml:"to"`
31+
32+
TextTwilioTriggered string `yaml:"text-twilio-triggered,omitempty"` // String used in the SMS body and subject (optional)
33+
TextTwilioResolved string `yaml:"text-twilio-resolved,omitempty"` // String used in the SMS body and subject (optional)
3034
}
3135

3236
func (cfg *Config) Validate() error {
@@ -58,6 +62,12 @@ func (cfg *Config) Merge(override *Config) {
5862
if len(override.To) > 0 {
5963
cfg.To = override.To
6064
}
65+
if len(override.TextTwilioTriggered) > 0 {
66+
cfg.TextTwilioTriggered = override.TextTwilioTriggered
67+
}
68+
if len(override.TextTwilioResolved) > 0 {
69+
cfg.TextTwilioResolved = override.TextTwilioResolved
70+
}
6171
}
6272

6373
// AlertProvider is the configuration necessary for sending an alert using Twilio
@@ -102,9 +112,17 @@ func (provider *AlertProvider) Send(ep *endpoint.Endpoint, alert *alert.Alert, r
102112
func (provider *AlertProvider) buildRequestBody(cfg *Config, ep *endpoint.Endpoint, alert *alert.Alert, result *endpoint.Result, resolved bool) string {
103113
var message string
104114
if resolved {
105-
message = fmt.Sprintf("RESOLVED: %s - %s", ep.DisplayName(), alert.GetDescription())
115+
if len(cfg.TextTwilioResolved) > 0 {
116+
message = strings.Replace(strings.Replace(cfg.TextTwilioResolved, "{endpoint}", ep.DisplayName(), 1), "{description}", alert.GetDescription(), 1)
117+
} else {
118+
message = fmt.Sprintf("RESOLVED: %s - %s", ep.DisplayName(), alert.GetDescription())
119+
}
106120
} else {
107-
message = fmt.Sprintf("TRIGGERED: %s - %s", ep.DisplayName(), alert.GetDescription())
121+
if len(cfg.TextTwilioTriggered) > 0 {
122+
message = strings.Replace(strings.Replace(cfg.TextTwilioTriggered, "{endpoint}", ep.DisplayName(), 1), "{description}", alert.GetDescription(), 1)
123+
} else {
124+
message = fmt.Sprintf("TRIGGERED: %s - %s", ep.DisplayName(), alert.GetDescription())
125+
}
108126
}
109127
return url.Values{
110128
"To": {cfg.To},

0 commit comments

Comments
 (0)