Commit a2b62a0c authored by 刘基明's avatar 刘基明

内容超长error fix

parent 0d64e1bf
...@@ -517,16 +517,20 @@ public class ThemeManager { ...@@ -517,16 +517,20 @@ public class ThemeManager {
String content = sb.toString(); String content = sb.toString();
// 腾讯云接口最多支持5000文字校验,超过5000执行2次 // 腾讯云接口最多支持5000文字校验,超过5000执行2次
// 检查内容是否涉黄违法 // 检查内容是否涉黄违法
boolean b = TencentcloudUtils.textModeration(content.length() > 5000 ? content.substring(0, 5000) : content); boolean b;
while (content.length()>5000){
b = TencentcloudUtils.textModeration(content.substring(0, 5000));
if (!b) { if (!b) {
throw new BizException(ErrorCodeConstant.CONTENT_ILLEGAL); throw new BizException(ErrorCodeConstant.CONTENT_ILLEGAL);
} }
if (content.length() > 5000) { content=content.substring(5000);
boolean result = TencentcloudUtils.textModeration(content.substring(5000, content.length()));
if (!result) {
throw new BizException(ErrorCodeConstant.CONTENT_ILLEGAL);
} }
b = TencentcloudUtils.textModeration(content);
if (!b) {
throw new BizException(ErrorCodeConstant.CONTENT_ILLEGAL);
} }
} }
......
...@@ -88,7 +88,6 @@ public class TencentcloudUtils { ...@@ -88,7 +88,6 @@ public class TencentcloudUtils {
// suggestion Block 不通过 // suggestion Block 不通过
if (res.getSuggestion().equals("Block")) { if (res.getSuggestion().equals("Block")) {
return false; return false;
// return CommonResp.error(CommonResp.CONTENT_ILLEGAL, getTextLabel(res.getLabel(), res.getKeywords()));
} }
} catch (TencentCloudSDKException e) { } catch (TencentCloudSDKException e) {
log.error("调用腾文本内容安全异常"); log.error("调用腾文本内容安全异常");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment