-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.go
49 lines (44 loc) · 1.51 KB
/
settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package ssstatus
import (
"github.com/SoulSec/ssstatus/notify"
)
type Settings struct {
Monitor *MonitorSettings
Notifications *NotificationSettings
}
type MonitorSettings struct {
CheckInterval int `json:"checkInterval"`
Timeout int `json:"timeout"`
MaxConnection int `json:"maxConnection"`
ExponentialBackoffSeconds int `json:exponentialBackoffSeconds`
}
type NotificationSettings struct {
Email []*notify.EmailSettings `json:"email"`
Sms []*notify.SmsSettings `json:"sms"`
Telegram []*notify.TelegramSettings `json:"telegram"`
Pushover []*notify.PushoverSettings `json:"pushover"`
Webhook []*notify.WebhookSettings `json:"webhook"`
}
func (n *NotificationSettings) GetNotifiers() (notifiers notify.Notifiers) {
for _, email := range n.Email {
emailNotifier := ¬ify.EmailNotifier{Settings: email}
notifiers = append(notifiers, emailNotifier)
}
for _, sms := range n.Sms {
smsNotifier := ¬ify.SmsNotifier{Settings: sms}
notifiers = append(notifiers, smsNotifier)
}
for _, telegram := range n.Telegram {
telegramNotifier := ¬ify.TelegramNotifier{Settings: telegram}
notifiers = append(notifiers, telegramNotifier)
}
for _, pushover := range n.Pushover {
pushoverNotifier := ¬ify.PushoverNotifier{Settings: pushover}
notifiers = append(notifiers, pushoverNotifier)
}
for _, webhook := range n.Webhook {
webhookNotifier := ¬ify.WebhookNotifier{Settings: webhook}
notifiers = append(notifiers, webhookNotifier)
}
return
}