Эх сурвалжийг харах

只有小程序登录的用户才走敏感词过滤

xiexiaoyuan 2 жил өмнө
parent
commit
52a86f0b44
1 өөрчлөгдсөн 16 нэмэгдсэн , 12 устгасан
  1. 16 12
      services/comment/comment.go

+ 16 - 12
services/comment/comment.go

@@ -44,7 +44,7 @@ func Comment(user user.UserInfo, req reqComment.ReqComment) (ret response.RespCo
 		err = errors.New("请输入报告ID")
 		return
 	}
-	// todo 判断是否有留言权限
+	// 判断是否有留言权限
 	err, errMsg = services.CheckSimpleCompanyProduct(user)
 	if err != nil {
 		return
@@ -63,21 +63,25 @@ func Comment(user user.UserInfo, req reqComment.ReqComment) (ret response.RespCo
 		}
 	}
 	// 敏感词过滤
-	checkResult, err := wx_app.MsgSecCheck(user.OpenID, req.Content)
-	if err == nil {
-		if checkResult.Result != nil {
-			if checkResult.Result.Suggest != "pass" {
-				errMsg = "含有违禁词,不允许发布:" + checkResult.Result.Suggest +".命中标签:"+strconv.Itoa(checkResult.Result.Label)
-				err = errors.New("含有违禁词,不允许发布")
-				return
+	if user.RecordInfo.OpenID != "" && user.RecordInfo.CreatePlatform == 6 {   //只有小程序的用户才能走敏感词过滤接口
+		checkResult, tErr := wx_app.MsgSecCheck(user.RecordInfo.OpenID, req.Content)
+		/*if tErr != nil {
+			errMsg = "敏感词过滤失败" + tErr.Error()
+			err = errors.New("敏感词过滤失败")
+			return
+		}*/
+		if tErr == nil {
+			if checkResult.Result != nil {
+				if checkResult.Result.Suggest != "pass" {
+					errMsg = "含有违禁词,不允许发布:" + checkResult.Result.Suggest +".命中标签:"+strconv.Itoa(checkResult.Result.Label)
+					err = errors.New("含有违禁词,不允许发布")
+					return
+				}
 			}
 		}
-	}else{
-		/*errMsg = "敏感词过滤失败" + err.Error()
-		err = errors.New("敏感词过滤失败")
-		return*/
 	}
 
+
 	//新增留言
 	now := time.Now()
 	commentInfo := &yb_comment.YbComment{