|
@@ -169,7 +169,7 @@ class PostRepository
|
|
|
'post_cover' => $post->img,
|
|
|
'target_id' => $post->uid,
|
|
|
'action_id' => $post->id,
|
|
|
- ]);
|
|
|
+ ]);
|
|
|
}
|
|
|
|
|
|
return Response::create();
|
|
@@ -270,7 +270,7 @@ class PostRepository
|
|
|
//验证小号
|
|
|
$userInfo = $this->getUserInfo($request['uid']);
|
|
|
Log::debug('评论&回复小号' . json_encode($userInfo));
|
|
|
- if (!$userInfo || $userInfo['type'] != 1) {
|
|
|
+ if (!$userInfo || !$userInfo['data'] || $userInfo['data']['type'] != 1) {
|
|
|
return Response::create([
|
|
|
'message' => '所选小号信息有误',
|
|
|
'status_code' => 500
|
|
@@ -288,13 +288,16 @@ class PostRepository
|
|
|
'uid' => $request['uid'],
|
|
|
'post_id' => $request['post_id'],
|
|
|
'parent_id' => 0,
|
|
|
- 'username' => $userInfo['username'],
|
|
|
+ 'username' => $userInfo['data']['username'],
|
|
|
'reply_uid' => 0,
|
|
|
'reply_username' => '',
|
|
|
- 'avatar' => $userInfo['avatar'],
|
|
|
+ 'avatar' => $userInfo['data']['avatar'],
|
|
|
'content' => $request['content'],
|
|
|
'is_delete' => 0,
|
|
|
];
|
|
|
+ $parentCommentContent = '';
|
|
|
+ $parentCommentUid = 0;
|
|
|
+ $parentCommentTime = '';
|
|
|
if (isset($request['parent_id']) && $request['parent_id'] != 0) {
|
|
|
$comment = $this->postComment->find($request['parent_id']);
|
|
|
if (!$comment) {
|
|
@@ -312,14 +315,44 @@ class PostRepository
|
|
|
$data['parent_id'] = $request['parent_id'];
|
|
|
$data['reply_uid'] = $comment->uid;
|
|
|
$data['reply_username'] = $comment->username;
|
|
|
+ $parentCommentContent = $comment->content;
|
|
|
+ $parentCommentUid = $comment->uid;
|
|
|
+ $parentCommentTime = Carbon::parse($comment->created_at)->toDateTimeString();
|
|
|
}
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
- $this->postComment->create($data);
|
|
|
+ $comment = $this->postComment->create($data);
|
|
|
$post->data->comment_count += 1;
|
|
|
$post->data->save();
|
|
|
|
|
|
DB::commit();
|
|
|
+
|
|
|
+ $virus = $this->behavior->where('behavior_identification', 'comment')->first();
|
|
|
+ if($virus){
|
|
|
+ if($post->title){
|
|
|
+ $desc = $post->title;
|
|
|
+ }else{
|
|
|
+ $desc = subtext(strip_tags($post->content), 20);
|
|
|
+ }
|
|
|
+ $this->rabbitMqUtil->push('virus_add', [
|
|
|
+ 'behavior_id' => $virus->virus_behavior_id,
|
|
|
+ 'behavior_flag' => 'comment',
|
|
|
+ 'post_id' => $post->id,
|
|
|
+ 'post_author_uid' => $post->uid,
|
|
|
+ 'post_desc' => $desc,
|
|
|
+ 'post_cover' => $post->img,
|
|
|
+ 'comment_id' => $comment->id,
|
|
|
+ 'comment_content' => $comment->content,
|
|
|
+ 'parent_comment_id' => $comment->parent_id,
|
|
|
+ 'parent_comment_content' => $parentCommentContent,
|
|
|
+ 'parent_comment_uid' => $parentCommentUid,
|
|
|
+ 'parent_comment_time' => $parentCommentTime,
|
|
|
+ 'reply_uid' => $comment->reply_uid,
|
|
|
+ 'reply_username' => $comment->reply_username,
|
|
|
+ 'target_id' => $comment->uid,
|
|
|
+ 'action_id' => $post->id,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
return Response::create();
|
|
|
|
|
|
} catch (QueryException $exception) {
|