diff --git a/controller/channel-test.go b/controller/channel-test.go index dbc7f599..d8b0769a 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -220,7 +220,16 @@ func disableChannel(channelId int, channelName string, reason string) { // enable func enableChannel(channelId int, channelName string) { + if common.RootUserEmail == "" { + common.RootUserEmail = model.GetRootUserEmail() + } model.UpdateChannelStatusById(channelId, common.ChannelStatusEnabled) + subject := fmt.Sprintf("通道「%s」(#%d)已被重新启用", channelName, channelId) + content := fmt.Sprintf("通道「%s」(#%d)通道现在满足了服务器要求, 已被重新启用并重新开始运行", channelName, channelId) + err := common.SendEmail(subject, common.RootUserEmail, content) + if err != nil { + common.SysError(fmt.Sprintf("failed to send email: %s", err.Error())) + } } func testAllChannels(notify bool) error { @@ -257,7 +266,7 @@ func testAllChannels(notify bool) error { disableChannel(channel.Id, channel.Name, err.Error()) } else if shouldDisableChannel(openaiErr, -1) { disableChannel(channel.Id, channel.Name, err.Error()) - } else if err == nil && openaiErr == nil && channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled { + } else if channel.Status == common.ChannelStatusAutoDisabled && common.AutoReEnableFailedChannelEnabled { enableChannel(channel.Id, channel.Name) } channel.UpdateResponseTime(milliseconds) diff --git a/i18n/en.json b/i18n/en.json index 341b1c18..993ddd02 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -638,6 +638,8 @@ "重新启用之前被自动禁用的故障通道": "Re-enable the failed channel automatically disabled before", "Turnstile 部件测试: (如果您的 Turnstile 模式设置为 不可见 模式,则不会显示此部件。)": "Turnstile widget test: (If your Turnstile mode is set to Invisible mode, this widget will not be displayed.)", + "通道「%s」(#%d)已被重新启用": "Channel '%s' (#%d) has been re-enabled", + "通道「%s」(#%d)通道现在满足了服务器要求, 已被重新启用并重新开始运行": "Channel '%s' (#%d) now meets the server requirements, has been re-enabled and restarted", "本项目 OneAPI 原作 JustSong ,由 ckt1031 改进,本源代码遵循 MIT 协议": "OneAPI by JustSong, improved by ckt1031, and follows MIT license", "警告": "Warning",