Commit 6503941f authored by 王浩's avatar 王浩

Merge branch 'haow/dev' into 'test'

fix code

See merge request alpha/saturn!96
parents b69c89e0 f47dfb70
......@@ -85,38 +85,33 @@ class CreatePictorial(BaseView):
)
return ret
def revise_comments(self, comments, from_id):
def revise_comments(self, comment, from_id):
ret = []
for obj in comments:
obj['from_id'] = from_id
obj['content'] = obj.get('comment')
reply = obj.pop('reply', None)
if not reply:
continue
for info in reply:
info['from_id'] = obj.get('from_id')
info['reply_id'] = obj.get('id')
info['type'] = obj.get('type')
ret.append(info)
return obj, ret
comment['from_id'] = from_id
comment['content'] = comment.get('comment')
reply = comment.pop('reply', None)
if not reply:
return comment, ret
for info in reply:
info['from_id'] = comment.get('from_id')
info['reply_id'] = comment.get('id')
info['type'] = comment.get('type')
ret.append(info)
return comment, ret
def create_comment(self, comment_list, from_id, platform, topic_id=None, pictorial_id=None):
top_comment, comments = self.revise_comments(comment_list, from_id)
top_comment['user_id'] = self.get_user_id(id_=top_comment.get('user').get('id'), platform=platform)
top_comment.pop('user')
error, ret = self.call_rpc('venus/community/crawl/replys', data=[top_comment], platform=platform, topic_id=topic_id, pictorial_id=pictorial_id)
if error:
return error, ret
top_id = ret.get('reply_ids')[0]
top_id = 0
for obj in comments:
obj['user_id'] = self.get_user_id(id_=obj.get('user').get('id'), platform=platform)
obj.pop('user')
error, _ = self.call_rpc('venus/community/crawl/replys', data=comments, platform=platform, topic_id=topic_id, pictorial_id=pictorial_id, top_id=top_id)
if error:
return error, None
......@@ -135,7 +130,8 @@ class CreatePictorial(BaseView):
continue
from_id = topic.get('id')
if platform == GRAP_PLATFORM.XIAOHONGSHU:
error, _ = self.create_comment(comment_list=topic_comments, from_id=from_id, platform=platform, topic_id=topic_obj.get('id'))
for topic_comment in topic_comments:
error, _ = self.create_comment(comment_list=topic_comment, from_id=from_id, platform=platform, topic_id=topic_obj.get('id'))
if error:
return error, _
......@@ -180,9 +176,10 @@ class CreatePictorial(BaseView):
return error, None
if pictorial_comments:
if platform == GRAP_PLATFORM.XIAOHONGSHU:
error, _ = self.create_comment(comment_list=pictorial_comments, from_id=pictorial.get('id'), platform=platform, pictorial_id=pictorial_id)
if error:
return error, _
for pictorial_comment in pictorial_comments:
error, _ = self.create_comment(comment_list=pictorial_comment, from_id=pictorial.get('id'), platform=platform, pictorial_id=pictorial_id)
if error:
return error, _
return None, None
......
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