Merge pull request #1387 from feitianbubu/alpha

fix: playground chat
This commit is contained in:
Calcium-Ion
2025-07-17 19:14:34 +08:00
committed by GitHub
2 changed files with 14 additions and 3 deletions

View File

@@ -65,9 +65,8 @@ func Playground(c *gin.Context) {
Group: group,
}
_ = middleware.SetupContextForToken(c, tempToken)
_, err = getChannel(c, group, playgroundRequest.Model, 0)
if err != nil {
newAPIError = types.NewError(err, types.ErrorCodeGetChannelFailed)
_, newAPIError = getChannel(c, group, playgroundRequest.Model, 1)
if newAPIError != nil {
return
}
//middleware.SetupContextForSelectedChannel(c, channel, playgroundRequest.Model)

View File

@@ -123,6 +123,18 @@ func authHelper(c *gin.Context, minRole int) {
c.Set("id", id)
c.Set("group", session.Get("group"))
c.Set("use_access_token", useAccessToken)
userCache, err := model.GetUserCache(id.(int))
if err != nil {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": err.Error(),
})
c.Abort()
return
}
userCache.WriteContext(c)
c.Next()
}