mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-27 16:06:16 +01:00
move supportstitle to global var
This commit is contained in:
@@ -60,6 +60,24 @@ type SystemAlertData struct {
|
|||||||
descriptor string // override descriptor in notification body (for temp sensor, disk partition, etc)
|
descriptor string // override descriptor in notification body (for temp sensor, disk partition, etc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// notification services that support title param
|
||||||
|
var supportsTitle = map[string]struct{}{
|
||||||
|
"bark": {},
|
||||||
|
"discord": {},
|
||||||
|
"gotify": {},
|
||||||
|
"ifttt": {},
|
||||||
|
"join": {},
|
||||||
|
"matrix": {},
|
||||||
|
"ntfy": {},
|
||||||
|
"opsgenie": {},
|
||||||
|
"pushbullet": {},
|
||||||
|
"pushover": {},
|
||||||
|
"slack": {},
|
||||||
|
"teams": {},
|
||||||
|
"telegram": {},
|
||||||
|
"zulip": {},
|
||||||
|
}
|
||||||
|
|
||||||
func NewAlertManager(app core.App) *AlertManager {
|
func NewAlertManager(app core.App) *AlertManager {
|
||||||
return &AlertManager{
|
return &AlertManager{
|
||||||
app: app,
|
app: app,
|
||||||
@@ -446,9 +464,6 @@ func (am *AlertManager) sendAlert(data AlertMessageData) {
|
|||||||
|
|
||||||
// SendShoutrrrAlert sends an alert via a Shoutrrr URL
|
// SendShoutrrrAlert sends an alert via a Shoutrrr URL
|
||||||
func (am *AlertManager) SendShoutrrrAlert(notificationUrl, title, message, link, linkText string) error {
|
func (am *AlertManager) SendShoutrrrAlert(notificationUrl, title, message, link, linkText string) error {
|
||||||
// services that support title param
|
|
||||||
supportsTitle := []string{"bark", "discord", "gotify", "ifttt", "join", "matrix", "ntfy", "opsgenie", "pushbullet", "pushover", "slack", "teams", "telegram", "zulip"}
|
|
||||||
|
|
||||||
// Parse the URL
|
// Parse the URL
|
||||||
parsedURL, err := url.Parse(notificationUrl)
|
parsedURL, err := url.Parse(notificationUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -458,7 +473,7 @@ func (am *AlertManager) SendShoutrrrAlert(notificationUrl, title, message, link,
|
|||||||
queryParams := parsedURL.Query()
|
queryParams := parsedURL.Query()
|
||||||
|
|
||||||
// Add title
|
// Add title
|
||||||
if sliceContains(supportsTitle, scheme) {
|
if _, ok := supportsTitle[scheme]; ok {
|
||||||
queryParams.Add("title", title)
|
queryParams.Add("title", title)
|
||||||
} else if scheme == "mattermost" {
|
} else if scheme == "mattermost" {
|
||||||
// use markdown title for mattermost
|
// use markdown title for mattermost
|
||||||
|
|||||||
Reference in New Issue
Block a user