Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
saturn
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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpha
saturn
Commits
c2099d0c
Commit
c2099d0c
authored
Dec 21, 2018
by
zhanglu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
敏感词接入
parent
f8ef7a8a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
sensitive.py
api/utils/sensitive.py
+1
-1
topic.py
api/views/topic.py
+22
-9
No files found.
api/utils/sensitive.py
View file @
c2099d0c
...
...
@@ -60,7 +60,7 @@ class Sensitive(object):
for
res
in
spawn
.
result
:
data
.
append
(
cls
.
_yidun_paraser
(
res
,
False
))
for
text
,
r
in
(
text_list
,
data
):
for
text
,
r
in
zip
(
text_list
,
data
):
result
[
text
]
=
r
return
result
...
...
api/views/topic.py
View file @
c2099d0c
...
...
@@ -2,7 +2,7 @@ import json
from
api.views.base_view
import
BaseView
from
lib
s.sensitive
import
Sensitive
from
api.util
s.sensitive
import
Sensitive
class
CreateTopicForBatch
(
BaseView
):
...
...
@@ -20,31 +20,44 @@ class CreateTopicForBatch(BaseView):
if
not
topic_list
:
return
self
.
ok
()
# TODO: 过滤topic.content敏感词
topics
=
[]
# 敏感词检测,获取可用的帖子
check_info
=
Sensitive
.
check
([
topic
[
"content"
]
for
topic
in
topic_list
if
topic
.
get
(
"content"
)])
for
topic
in
topic_list
:
succ
=
check_info
.
get
(
topic
.
get
(
"content"
))
if
topic
.
get
(
"content"
)
else
True
if
not
succ
:
topics
.
append
(
topic
)
if
not
topics
:
return
self
.
ok
()
tag_names
=
[]
for
item
in
topic
_list
:
for
item
in
topic
s
:
tag_names
.
extend
(
item
.
get
(
"tags"
,
[]))
item
[
"user_id"
]
=
user_id
check_info
=
Sensitive
.
check
(
list
(
filter
(
None
,
set
(
tag_names
)))
)
tags
=
check_info
.
values
()
check_info
=
Sensitive
.
check
(
tag_names
)
tags
=
[
tag_name
for
tag_name
,
succ
in
check_info
.
items
()
if
not
succ
]
# 先创建标签
_tag_error
,
_tag_data
=
self
.
call_rpc
(
"venus/community/tag/batch_create_tag_by_name"
,
tag_names
=
list
(
tags
)
tag_names
=
tags
)
if
_tag_error
:
return
self
.
error
(
_tag_error
)
# 更新发帖
for
item
in
topic_list
:
item
[
"tag_ids"
]
=
[
_tag_data
.
get
(
tag_name
,
0
)
for
tag_name
in
item
.
get
(
"tags"
,
[])]
for
item
in
topics
:
item
[
"tag_ids"
]
=
[
_tag_data
[
tag_name
]
for
tag_name
in
item
.
get
(
"tags"
,
[])
if
_tag_data
.
get
(
tag_name
)
]
print
(
topics
)
create_err
,
result
=
self
.
call_rpc
(
"venus/community/topic/batch_create_for_inner"
,
topic_list
=
topic
_list
topic_list
=
topic
s
)
if
create_err
:
return
self
.
error
(
create_err
)
...
...
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