Skip to content

Commit

Permalink
fix subscription detection error: prefix override
Browse files Browse the repository at this point in the history
  • Loading branch information
zmh-program committed Nov 22, 2023
1 parent fcff8ab commit cec5011
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions manager/transhipment.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ func TranshipmentAPI(c *gin.Context) {
id := utils.Md5Encrypt(username + form.Model + time.Now().String())
created := time.Now().Unix()

if strings.HasPrefix(form.Model, "web-") {
suffix := strings.TrimPrefix(form.Model, "web-")
if utils.Contains[string](suffix, globals.AllModels) {
form.Model = suffix
form.Messages = web.UsingWebNativeSegment(true, form.Messages)
}
}

check, plan := auth.CanEnableModelWithSubscription(db, cache, user, form.Model)
if !check {
c.JSON(http.StatusForbidden, gin.H{
Expand All @@ -118,14 +126,6 @@ func TranshipmentAPI(c *gin.Context) {
return
}

if strings.HasPrefix(form.Model, "web-") {
suffix := strings.TrimPrefix(form.Model, "web-")
if utils.Contains[string](suffix, globals.AllModels) {
form.Model = suffix
form.Messages = web.UsingWebNativeSegment(true, form.Messages)
}
}

if form.Stream {
sendStreamTranshipmentResponse(c, form, id, created, user, plan)
} else {
Expand Down

0 comments on commit cec5011

Please sign in to comment.