mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-04 21:33:41 +08:00
fix: do not consume user quota if failed
This commit is contained in:
@@ -170,6 +170,9 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
|
||||
var textResponse ImageResponse
|
||||
defer func(ctx context.Context) {
|
||||
if consumeQuota {
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return
|
||||
}
|
||||
err := model.PostConsumeTokenQuota(tokenId, userQuota, quota, 0, true)
|
||||
if err != nil {
|
||||
common.SysError("error consuming token remain quota: " + err.Error())
|
||||
|
||||
Reference in New Issue
Block a user