Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
2fdd87b7
Commit
2fdd87b7
authored
Sep 28, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文本校验打印违规关键字fix
parent
058d0c2c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
11 deletions
+9
-11
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+5
-6
TencentcloudUtils.java
...main/java/com/tanpu/community/util/TencentcloudUtils.java
+4
-5
No files found.
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
2fdd87b7
...
...
@@ -8,7 +8,6 @@ import com.tanpu.biz.common.enums.RelTypeEnum;
import
com.tanpu.biz.common.enums.community.CollectionTypeEnum
;
import
com.tanpu.biz.common.enums.community.ReportTypeEnum
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.ResultCode
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.exception.BizException
;
...
...
@@ -828,17 +827,17 @@ public class ThemeManager {
String
content
=
sb
.
toString
();
// 腾讯云接口最多支持5000文字校验
// 检查内容是否涉黄违法
boolean
b
;
String
b
=
""
;
while
(
content
.
length
()
>
5000
)
{
b
=
TencentcloudUtils
.
textModeration
(
content
.
substring
(
0
,
5000
));
if
(
!
b
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
);
if
(
StringUtils
.
isNotBlank
(
b
)
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
.
getCode
(),
ErrorCodeConstant
.
CONTENT_ILLEGAL
.
getMsg
()+
":"
);
}
content
=
content
.
substring
(
5000
);
}
b
=
TencentcloudUtils
.
textModeration
(
content
);
if
(
!
b
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
);
if
(
StringUtils
.
isNotBlank
(
b
)
)
{
throw
new
BizException
(
ErrorCodeConstant
.
CONTENT_ILLEGAL
.
getCode
(),
ErrorCodeConstant
.
CONTENT_ILLEGAL
.
getMsg
()+
":"
);
}
...
...
community-service/src/main/java/com/tanpu/community/util/TencentcloudUtils.java
View file @
2fdd87b7
...
...
@@ -79,7 +79,7 @@ public class TencentcloudUtils {
* @param text
* @return
*/
public
static
boolean
textModeration
(
String
text
)
{
public
static
String
textModeration
(
String
text
)
{
TextModerationRequest
req
=
new
TextModerationRequest
();
req
.
setContent
(
Base64
.
getEncoder
().
encodeToString
(
text
.
getBytes
(
StandardCharsets
.
UTF_8
)));
TextModerationResponse
res
=
null
;
...
...
@@ -87,16 +87,15 @@ public class TencentcloudUtils {
res
=
getTmsClient
().
TextModeration
(
req
);
// suggestion Block 不通过
if
(
res
.
getSuggestion
().
equals
(
"Block"
))
{
log
.
error
(
"文本检验违规关键字:"
+
res
.
getKeywords
());
return
false
;
return
res
.
getKeywords
().
toString
();
}
}
catch
(
TencentCloudSDKException
e
)
{
log
.
error
(
"调用腾文本内容安全异常"
);
e
.
printStackTrace
();
//调用失败时,不影响用户发布主题
return
true
;
return
""
;
}
return
true
;
return
""
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment