- Updated API to support Telegram as a notification provider type. - Enhanced tests to cover Telegram provider creation, updates, and token handling. - Modified frontend forms to include Telegram-specific fields and validation. - Added localization strings for Telegram provider. - Implemented security measures to ensure bot tokens are not exposed in API responses.
32 lines
641 B
Go
32 lines
641 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]
|
|
default:
|
|
return false
|
|
}
|
|
}
|