Commit 6e07d665 authored by 王浩's avatar 王浩

Merge branch 'haow/hotfix' into 'master'

add check sensitive in topic crawl from app

See merge request !69
parents 4c15a57a 2cfc4b5b
import json
from api.views.base_view import BaseView
from alpha_types.venus.enum import REPLY_TYPE
from api.utils.sensitive import Sensitive
class CreateReplyForInner(BaseView):
"""
内部使用,创建评论回复
"""
def check_sensitive_content(self, content):
# 敏感词检测,获取可用的帖子
check_info = Sensitive.check([content])
succ = check_info.get(content)
if not succ:
return content
else:
return
def post(self, request):
user_id = request.POST.get('user_id')
topic_id = request.POST.get('topic_id')
content = request.POST.get('content', '')
replied_id = request.POST.get('replied_id')
reply_type = request.POST.get('type', REPLY_TYPE.PUPPET_REPLY)
if reply_type not in (REPLY_TYPE.PUPPET_REPLY, REPLY_TYPE.PUPPET_REPLY_ANS):
if not self.check_sensitive_content(content):
return
error, data = self.call_rpc('venus/community/reply/for_inner_create', user_id=user_id, topic_id=topic_id, content=content, replied_id=replied_id)
error, data = self.call_rpc('venus/community/reply/for_inner_create',
user_id=user_id, topic_id=topic_id, content=content,
replied_id=replied_id, reply_type=reply_type)
if error:
return self.error(error)
......
......@@ -123,6 +123,8 @@ class CreateTopicForBatch(BaseView):
topic_list = json.loads(request.POST.get("topic_list", '[]'))
pictorial_tag_ids = json.loads(request.POST.get("tag_ids", '[]'))
is_app = request.POST.get('is_app', None)
info_logger.info({
'user_id': user_id,
'card_level': card_level,
......@@ -144,8 +146,13 @@ class CreateTopicForBatch(BaseView):
return self.ok()
# 敏感词检测,获取可用的帖子
# checked_topics = self.check_sensitive_content(topic_list)
checked_topics = topic_list
if is_app:
if int(is_app) == 1:
checked_topics = self.check_sensitive_content(topic_list)
else:
checked_topics = topic_list
else:
checked_topics = topic_list
topics = []
for topic in checked_topics:
......
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