30 lines
689 B
Go
30 lines
689 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) (ChannelSender, error) {
|
|
switch channelType {
|
|
case "dingtalk":
|
|
return &DingTalkSender{}, nil
|
|
case "wecom":
|
|
return &WeComSender{}, nil
|
|
case "bark":
|
|
return &BarkSender{}, nil
|
|
case "email":
|
|
return nil, fmt.Errorf("email sender not yet implemented (see Task 10)")
|
|
default:
|
|
return nil, fmt.Errorf("unknown channel type: %s", channelType)
|
|
}
|
|
}
|