mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-14 06:20:27 +00:00
feat: able to send alert message via message pusher (close #993)
This commit is contained in:
@@ -5,14 +5,23 @@ import (
|
||||
"github.com/songquanpeng/one-api/common"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/logger"
|
||||
"github.com/songquanpeng/one-api/common/message"
|
||||
"github.com/songquanpeng/one-api/model"
|
||||
)
|
||||
|
||||
func notifyRootUser(subject string, content string) {
|
||||
if config.MessagePusherAddress != "" {
|
||||
err := message.SendMessage(subject, content, content)
|
||||
if err != nil {
|
||||
logger.SysError(fmt.Sprintf("failed to send message: %s", err.Error()))
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
if config.RootUserEmail == "" {
|
||||
config.RootUserEmail = model.GetRootUserEmail()
|
||||
}
|
||||
err := common.SendEmail(subject, config.RootUserEmail, content)
|
||||
err := message.SendEmail(subject, config.RootUserEmail, content)
|
||||
if err != nil {
|
||||
logger.SysError(fmt.Sprintf("failed to send email: %s", err.Error()))
|
||||
}
|
||||
|
Reference in New Issue
Block a user