Add/edit notifications
This commit is contained in:
parent
1ede36b8aa
commit
c7ad2aa1b6
19 changed files with 531 additions and 11 deletions
|
|
@ -6,6 +6,12 @@ import (
|
|||
|
||||
// Standard
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
allServices []Service
|
||||
)
|
||||
|
||||
func ServiceFactory(t string, config []byte, prio int, ackURL string, logger *slog.Logger) (Service, error) {
|
||||
|
|
@ -30,3 +36,25 @@ func ServiceFactory(t string, config []byte, prio int, ackURL string, logger *sl
|
|||
|
||||
return nil, werr.New("Unknown notification service, '%s'", t).WithCode("002-0000")
|
||||
}
|
||||
|
||||
func GetInstance(typ string) Service {
|
||||
for _, svc := range allServices {
|
||||
if strings.ToLower(svc.GetType()) == strings.ToLower(typ) {
|
||||
return svc
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func AvailableServices() []Service {
|
||||
slices.SortFunc(allServices, func(a, b Service) int {
|
||||
if a.GetType() < b.GetType() {
|
||||
return -1
|
||||
}
|
||||
if a.GetType() > b.GetType() {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
return allServices
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue