Update channel.go

This commit is contained in:
analogpvt 2023-05-19 22:44:06 +05:30 committed by GitHub
parent 9b033b7ebe
commit d0e4687607
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -270,11 +270,11 @@ func disableChannel(channelId int, channelName string, reason string) {
common.RootUserEmail = model.GetRootUserEmail() common.RootUserEmail = model.GetRootUserEmail()
} }
model.UpdateChannelStatusById(channelId, common.ChannelStatusDisabled) model.UpdateChannelStatusById(channelId, common.ChannelStatusDisabled)
subject := fmt.Sprintf("通道「%s」#%d已被禁用", channelName, channelId) subject := fmt.Sprintf("Channel「%s」#%dhas been disabled", channelName, channelId)
content := fmt.Sprintf("通道「%s」#%d已被禁用原因%s", channelName, channelId, reason) content := fmt.Sprintf("Channel「%s」#%dhas been disabled, reason%s", channelName, channelId, reason)
err := common.SendEmail(subject, common.RootUserEmail, content) err := common.SendEmail(subject, common.RootUserEmail, content)
if err != nil { if err != nil {
common.SysError(fmt.Sprintf("发送邮件失败%s", err.Error())) common.SysError(fmt.Sprintf("Failed to send mail%s", err.Error()))
} }
} }
@ -282,7 +282,7 @@ func testAllChannels(c *gin.Context) error {
testAllChannelsLock.Lock() testAllChannelsLock.Lock()
if testAllChannelsRunning { if testAllChannelsRunning {
testAllChannelsLock.Unlock() testAllChannelsLock.Unlock()
return errors.New("测试已在运行中") return errors.New("Test is already running")
} }
testAllChannelsRunning = true testAllChannelsRunning = true
testAllChannelsLock.Unlock() testAllChannelsLock.Unlock()
@ -310,15 +310,15 @@ func testAllChannels(c *gin.Context) error {
milliseconds := tok.Sub(tik).Milliseconds() milliseconds := tok.Sub(tik).Milliseconds()
if err != nil || milliseconds > disableThreshold { if err != nil || milliseconds > disableThreshold {
if milliseconds > disableThreshold { if milliseconds > disableThreshold {
err = errors.New(fmt.Sprintf("响应时间 %.2fs 超过阈值 %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0)) err = errors.New(fmt.Sprintf("Response time %.2fs Threshold exceeded %.2fs", float64(milliseconds)/1000.0, float64(disableThreshold)/1000.0))
} }
disableChannel(channel.Id, channel.Name, err.Error()) disableChannel(channel.Id, channel.Name, err.Error())
} }
channel.UpdateResponseTime(milliseconds) channel.UpdateResponseTime(milliseconds)
} }
err := common.SendEmail("通道测试完成", common.RootUserEmail, "通道测试完成,如果没有收到禁用通知,说明所有通道都正常") err := common.SendEmail("Channel test complete", common.RootUserEmail, "The channel test is completed, if no disable notification is received, all channels are normal")
if err != nil { if err != nil {
common.SysError(fmt.Sprintf("发送邮件失败%s", err.Error())) common.SysError(fmt.Sprintf("Failed to send mail%s", err.Error()))
} }
testAllChannelsLock.Lock() testAllChannelsLock.Lock()
testAllChannelsRunning = false testAllChannelsRunning = false