fix: check user quota when pre-consume quota

This commit is contained in:
JustSong
2023-10-01 12:49:40 +08:00
parent 53b2cace0b
commit 47c08c72ce
3 changed files with 8 additions and 1 deletions

View File

@@ -99,7 +99,7 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
quota := int(ratio*sizeRatio*1000) * imageRequest.N
if consumeQuota && userQuota-quota < 0 {
return errorWrapper(err, "insufficient_user_quota", http.StatusForbidden)
return errorWrapper(errors.New("user quota is not enough"), "insufficient_user_quota", http.StatusForbidden)
}
req, err := http.NewRequest(c.Request.Method, fullRequestURL, requestBody)