From 1ddcff95086cd05ccac0fbdd27338ea9915780c8 Mon Sep 17 00:00:00 2001 From: nianhua99 <1139168548@qq.com> Date: Thu, 14 Nov 2024 00:11:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=8D=E4=BB=A3=E5=90=8E=E6=B5=81?= =?UTF-8?q?=E5=BC=8F=E8=BE=93=E5=87=BA=E6=84=8F=E5=A4=96=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20fix:=20=E5=8F=8D=E4=BB=A3?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E5=8F=91=E9=80=81=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=92=8C=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98=20feat:?= =?UTF-8?q?=20=E5=90=8E=E5=8F=B0=E7=99=BB=E5=BD=95=E6=94=AF=E6=8C=812FA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/middleware/moderation.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/middleware/moderation.go b/internal/middleware/moderation.go index 8c4f14a..fefb4d0 100644 --- a/internal/middleware/moderation.go +++ b/internal/middleware/moderation.go @@ -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 } @@ -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 }