mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
feat: 只自动启用被自动禁用的渠道 (close #224)
This commit is contained in:
parent
db575a1c25
commit
ecd06cf2f8
@ -208,7 +208,7 @@ func testAllChannels(notify bool) error {
|
|||||||
if isChannelEnabled && service.ShouldDisableChannel(openaiErr, -1) && ban {
|
if isChannelEnabled && service.ShouldDisableChannel(openaiErr, -1) && ban {
|
||||||
service.DisableChannel(channel.Id, channel.Name, err.Error())
|
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)
|
service.EnableChannel(channel.Id, channel.Name)
|
||||||
}
|
}
|
||||||
channel.UpdateResponseTime(milliseconds)
|
channel.UpdateResponseTime(milliseconds)
|
||||||
|
@ -63,7 +63,7 @@ func ShouldDisableChannel(err *relaymodel.OpenAIError, statusCode int) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShouldEnableChannel(err error, openAIErr *relaymodel.OpenAIError) bool {
|
func ShouldEnableChannel(err error, openAIErr *relaymodel.OpenAIError, status int) bool {
|
||||||
if !common.AutomaticEnableChannelEnabled {
|
if !common.AutomaticEnableChannelEnabled {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -73,5 +73,8 @@ func ShouldEnableChannel(err error, openAIErr *relaymodel.OpenAIError) bool {
|
|||||||
if openAIErr != nil {
|
if openAIErr != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if status != common.ChannelStatusAutoDisabled {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user