From 15737cd0cf1275a56f52dbf1e5f4ea2d65eb5c52 Mon Sep 17 00:00:00 2001 From: Ghostz Date: Fri, 21 Jun 2024 11:40:36 +0800 Subject: [PATCH] =?UTF-8?q?disabled=20channel=20when=20return=20=E6=97=A0?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E6=B8=A0=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- middleware/distributor.go | 7 ++++--- monitor/manage.go | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/middleware/distributor.go b/middleware/distributor.go index 0c4b04c3..32f3df5c 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -2,13 +2,14 @@ package middleware import ( "fmt" + "net/http" + "strconv" + "github.com/gin-gonic/gin" "github.com/songquanpeng/one-api/common/ctxkey" "github.com/songquanpeng/one-api/common/logger" "github.com/songquanpeng/one-api/model" "github.com/songquanpeng/one-api/relay/channeltype" - "net/http" - "strconv" ) type ModelRequest struct { @@ -48,7 +49,7 @@ func Distribute() func(c *gin.Context) { logger.SysError(fmt.Sprintf("渠道不存在:%d", channel.Id)) message = "数据库一致性已被破坏,请联系管理员" } - abortWithMessage(c, http.StatusServiceUnavailable, message) + abortWithMessage(c, http.StatusNotFound, message) return } } diff --git a/monitor/manage.go b/monitor/manage.go index 946e78af..d65fe3ce 100644 --- a/monitor/manage.go +++ b/monitor/manage.go @@ -1,10 +1,11 @@ package monitor import ( - "github.com/songquanpeng/one-api/common/config" - "github.com/songquanpeng/one-api/relay/model" "net/http" "strings" + + "github.com/songquanpeng/one-api/common/config" + "github.com/songquanpeng/one-api/relay/model" ) func ShouldDisableChannel(err *model.Error, statusCode int) bool { @@ -35,6 +36,8 @@ func ShouldDisableChannel(err *model.Error, statusCode int) bool { return true } else if strings.HasPrefix(err.Message, "This organization has been disabled.") { return true + } else if strings.HasPrefix(err.Message, "无可用渠道") { + return true } //if strings.Contains(err.Message, "quota") { // return true