Skip to content

Commit 1ddcff9

Browse files
committed
fix: 反代后流式输出意外停止的问题
fix: 反代后无法发送图片和文件的问题 feat: 后台登录支持2FA
1 parent bde0841 commit 1ddcff9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/middleware/moderation.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ func ContentModerationMiddleware(conf *viper.Viper, logger *log.Logger) gin.Hand
7272
return
7373
}
7474
if shouldBlock {
75-
c.JSON(http.StatusTooEarly, gin.H{"detail": conf.GetString("moderation.message")})
75+
result := map[string]interface{}{
76+
"detail": map[string]interface{}{
77+
"message": conf.GetString("moderation.message"),
78+
"flagged": true,
79+
},
80+
}
81+
c.JSON(http.StatusTooEarly, result)
7682
c.Abort()
7783
return
7884
}
@@ -130,6 +136,7 @@ func checkContentForModeration(messages []string, apiKey string, apiHost string,
130136
Post(apiHost)
131137

132138
if err != nil {
139+
logger.Error("Moderation API returned an error: {}", zap.Error(err))
133140
return false, err
134141
}
135142

0 commit comments

Comments
 (0)