39f3774940
统一 sources/templates/channels/rules 列表为分页响应,避免配置增多时全量返回;按钉钉 access_token 限制每分钟发送并在超限时等待下一分钟,降低触发官方封禁风险。 Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
711 B
Go
30 lines
711 B
Go
package adapter
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"aiaa-notification-service/internal/config"
|
|
)
|
|
|
|
// ChannelSender sends a rendered message to a specific channel.
|
|
type ChannelSender interface {
|
|
Type() string
|
|
Send(title, content string, config json.RawMessage) error
|
|
}
|
|
|
|
func NewSender(channelType string, smtpCfg *config.SMTPConfig, dingtalkLimiter *DingTalkLimiter) (ChannelSender, error) {
|
|
switch channelType {
|
|
case "dingtalk":
|
|
return &DingTalkSender{limiter: dingtalkLimiter}, nil
|
|
case "wecom":
|
|
return &WeComSender{}, nil
|
|
case "bark":
|
|
return &BarkSender{}, nil
|
|
case "email":
|
|
return NewEmailSender(*smtpCfg), nil
|
|
default:
|
|
return nil, fmt.Errorf("unknown channel type: %s", channelType)
|
|
}
|
|
}
|