mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-21 11:06:37 +08:00
commit
b5a242da15
@ -12,6 +12,22 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func Notify(by string, title string, description string, content string) error {
|
func Notify(by string, title string, description string, content string) error {
|
||||||
|
|
||||||
|
if by == ByAll {
|
||||||
|
var errMsgs []string
|
||||||
|
if err := SendEmail(title, config.RootUserEmail, content); err != nil {
|
||||||
|
errMsgs = append(errMsgs, fmt.Sprintf("failed to send email: %v", err))
|
||||||
|
}
|
||||||
|
if err := SendMessage(title, description, content); err != nil {
|
||||||
|
errMsgs = append(errMsgs, fmt.Sprintf("failed to send message: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(errMsgs) > 0 {
|
||||||
|
return fmt.Errorf("multiple errors occurred: %v", errMsgs)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if by == ByEmail {
|
if by == ByEmail {
|
||||||
return SendEmail(title, config.RootUserEmail, content)
|
return SendEmail(title, config.RootUserEmail, content)
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ func testChannels(ctx context.Context, notify bool, scope string) error {
|
|||||||
if notify {
|
if notify {
|
||||||
err := message.Notify(message.ByAll, "Channel test completed", "", "Channel test completed, if you have not received the disable notification, it means that all channels are normal")
|
err := message.Notify(message.ByAll, "Channel test completed", "", "Channel test completed, if you have not received the disable notification, it means that all channels are normal")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.SysError(fmt.Sprintf("failed to send email: %s", err.Error()))
|
logger.SysError(fmt.Sprintf("failed to send notify: %s", err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user