Skip to content

Commit

Permalink
Update reply pipelines, restore reply_count logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Dec 24, 2022
1 parent e10985e commit 0d780ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Jobs/CommentPipeline/CommentPipeline.php
Expand Up @@ -59,6 +59,12 @@ public function handle()
$target = $status->profile;
$actor = $comment->profile;

if(config('database.default') === 'mysql') {
$count = DB::select( DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)"), [ 'kid' => $status->id]);
$status->reply_count = count($count);
$status->save();
}

if ($actor->id === $target->id || $status->comments_disabled == true) {
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions app/Jobs/StatusPipeline/StatusReplyPipeline.php
Expand Up @@ -68,6 +68,12 @@ public function handle()
return 1;
}

if(config('database.default') === 'mysql') {
$count = DB::select( DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)"), [ 'kid' => $reply->id]);
$reply->reply_count = count($count);
$reply->save();
}

DB::transaction(function() use($target, $actor, $status) {
$notification = new Notification();
$notification->profile_id = $target->id;
Expand Down

0 comments on commit 0d780ff

Please sign in to comment.