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