- Updated the list of supported notification provider types to include 'ntfy'. - Modified the notification settings UI to accommodate the Ntfy provider, including form fields for topic URL and access token. - Enhanced localization files to include translations for Ntfy-related fields in German, English, Spanish, French, and Chinese. - Implemented tests for the Ntfy notification provider, covering form rendering, CRUD operations, payload contracts, and security measures. - Updated existing tests to account for the new Ntfy provider in various scenarios.
38 lines
810 B
Go
38 lines
810 B
Go
package notifications
|
|
|
|
import "strings"
|
|
|
|
// NOTE: used only in tests
|
|
type Router struct{}
|
|
|
|
func NewRouter() *Router {
|
|
return &Router{}
|
|
}
|
|
|
|
func (r *Router) ShouldUseNotify(providerType string, flags map[string]bool) bool {
|
|
if !flags[FlagNotifyEngineEnabled] {
|
|
return false
|
|
}
|
|
|
|
switch strings.ToLower(providerType) {
|
|
case "discord":
|
|
return flags[FlagDiscordServiceEnabled]
|
|
case "email":
|
|
return flags[FlagEmailServiceEnabled]
|
|
case "gotify":
|
|
return flags[FlagGotifyServiceEnabled]
|
|
case "webhook":
|
|
return flags[FlagWebhookServiceEnabled]
|
|
case "telegram":
|
|
return flags[FlagTelegramServiceEnabled]
|
|
case "slack":
|
|
return flags[FlagSlackServiceEnabled]
|
|
case "pushover":
|
|
return flags[FlagPushoverServiceEnabled]
|
|
case "ntfy":
|
|
return flags[FlagNtfyServiceEnabled]
|
|
default:
|
|
return false
|
|
}
|
|
}
|