Skip to content

Commit

Permalink
fix: 反代后流式输出意外停止的问题
Browse files Browse the repository at this point in the history
fix: 反代后无法发送图片和文件的问题
feat: 后台登录支持2FA
  • Loading branch information
nianhua99 committed Nov 13, 2024
1 parent bde0841 commit 1ddcff9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/middleware/moderation.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ func ContentModerationMiddleware(conf *viper.Viper, logger *log.Logger) gin.Hand
return
}
if shouldBlock {
c.JSON(http.StatusTooEarly, gin.H{"detail": conf.GetString("moderation.message")})
result := map[string]interface{}{
"detail": map[string]interface{}{
"message": conf.GetString("moderation.message"),
"flagged": true,
},
}
c.JSON(http.StatusTooEarly, result)
c.Abort()
return
}
Expand Down Expand Up @@ -130,6 +136,7 @@ func checkContentForModeration(messages []string, apiKey string, apiHost string,
Post(apiHost)

if err != nil {
logger.Error("Moderation API returned an error: {}", zap.Error(err))
return false, err
}

Expand Down

0 comments on commit 1ddcff9

Please sign in to comment.