mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-05 23:26:38 +08:00
feat(push): add telegram bot push notification channel
Implement TelegramPusher in pkg/push, register config schema in channels_definition.go, add validation in model/push_channel.go, update task routing, and update settings-tab.tsx UI validation.
This commit is contained in:
@@ -19,6 +19,8 @@ const (
|
||||
TypeCustom = "custom"
|
||||
// TypeEmail 邮件推送消息通道类型
|
||||
TypeEmail = "email"
|
||||
// TypeTelegram 电报机器人推送消息通道类型
|
||||
TypeTelegram = "telegram"
|
||||
)
|
||||
|
||||
// PushChannel 消息通道模型
|
||||
@@ -53,6 +55,10 @@ func (pc *PushChannel) Validate() error {
|
||||
pc.Type = TypeCustom
|
||||
}
|
||||
|
||||
if pc.Type == TypeTelegram && pc.URL == "" {
|
||||
pc.URL = "https://api.telegram.org"
|
||||
}
|
||||
|
||||
if pc.Name == "" {
|
||||
return errors.New("channel name is required")
|
||||
}
|
||||
@@ -77,6 +83,10 @@ func (pc *PushChannel) Validate() error {
|
||||
return validateJSON(pc.Other)
|
||||
case TypeEmail:
|
||||
// Email channel SMTP configs fall back to global settings, so they are not required to be filled.
|
||||
case TypeTelegram:
|
||||
if pc.Token == "" {
|
||||
return errors.New("telegram bot token is required")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user