From ecd06cf2f87b8021008730b9849ba0d6fdb1015e Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Sun, 12 May 2024 19:29:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=AA=E8=87=AA=E5=8A=A8=E5=90=AF?= =?UTF-8?q?=E7=94=A8=E8=A2=AB=E8=87=AA=E5=8A=A8=E7=A6=81=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E6=B8=A0=E9=81=93=20(close=20#224)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/channel-test.go | 2 +- service/channel.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/controller/channel-test.go b/controller/channel-test.go index f66e0d6..f37f309 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -208,7 +208,7 @@ func testAllChannels(notify bool) error { if isChannelEnabled && service.ShouldDisableChannel(openaiErr, -1) && ban { service.DisableChannel(channel.Id, channel.Name, err.Error()) } - if !isChannelEnabled && service.ShouldEnableChannel(err, openaiErr) { + if !isChannelEnabled && service.ShouldEnableChannel(err, openaiErr, channel.Status) { service.EnableChannel(channel.Id, channel.Name) } channel.UpdateResponseTime(milliseconds) diff --git a/service/channel.go b/service/channel.go index 82ffd77..41ca6b7 100644 --- a/service/channel.go +++ b/service/channel.go @@ -63,7 +63,7 @@ func ShouldDisableChannel(err *relaymodel.OpenAIError, statusCode int) bool { return false } -func ShouldEnableChannel(err error, openAIErr *relaymodel.OpenAIError) bool { +func ShouldEnableChannel(err error, openAIErr *relaymodel.OpenAIError, status int) bool { if !common.AutomaticEnableChannelEnabled { return false } @@ -73,5 +73,8 @@ func ShouldEnableChannel(err error, openAIErr *relaymodel.OpenAIError) bool { if openAIErr != nil { return false } + if status != common.ChannelStatusAutoDisabled { + return false + } return true }