From 64f9e5f560138eb692db4be156b766d29ac2c0be Mon Sep 17 00:00:00 2001 From: linzhaoming Date: Tue, 18 Jun 2024 17:32:23 +0800 Subject: [PATCH] fix: test all channel --- controller/channel-test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/controller/channel-test.go b/controller/channel-test.go index c7067d0..63d8404 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -219,13 +219,15 @@ func testAllChannels(notify bool) error { if channel.AutoBan != nil && *channel.AutoBan == 0 { ban = false } - openAiErrWithStatus := dto.OpenAIErrorWithStatusCode{ - StatusCode: -1, - Error: *openaiErr, - LocalError: false, - } - if isChannelEnabled && service.ShouldDisableChannel(&openAiErrWithStatus) && ban { - service.DisableChannel(channel.Id, channel.Name, err.Error()) + if openaiErr != nil && isChannelEnabled && ban { + openAiErrWithStatus := dto.OpenAIErrorWithStatusCode{ + StatusCode: -1, + Error: *openaiErr, + LocalError: false, + } + if service.ShouldDisableChannel(&openAiErrWithStatus) { + service.DisableChannel(channel.Id, channel.Name, err.Error()) + } } if !isChannelEnabled && service.ShouldEnableChannel(err, openaiErr, channel.Status) { service.EnableChannel(channel.Id, channel.Name)