From 45ecad2a070b6306a9624219ad3483a9f4266975 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 27 Nov 2019 19:57:23 -0700 Subject: [PATCH 1/2] Update CommentController, fix scope bug --- app/Http/Controllers/CommentController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 38c177562..ec8fb9208 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -61,6 +61,7 @@ class CommentController extends Controller } $reply = DB::transaction(function() use($comment, $status, $profile) { + $scope = $profile->is_private == true ? 'private' : 'public'; $autolink = Autolink::create()->autolink($comment); $reply = new Status(); $reply->profile_id = $profile->id; @@ -68,6 +69,8 @@ class CommentController extends Controller $reply->rendered = $autolink; $reply->in_reply_to_id = $status->id; $reply->in_reply_to_profile_id = $status->profile_id; + $reply->scope = $scope; + $reply->visibility = $scope; $reply->save(); $status->reply_count++; From 487de31788905461d4992453ab87bcfd7f836780 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 27 Nov 2019 20:13:07 -0700 Subject: [PATCH 2/2] Update PublicApiController, fix scope bug --- app/Http/Controllers/PublicApiController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 908fa06cd..7c7f19464 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -115,19 +115,22 @@ class PublicApiController extends Controller $this->scopeCheck($profile, $status); if(Auth::check()) { - $pid = Auth::user()->profile->id; - $filtered = UserFilter::whereUserId($pid) + $p = Auth::user()->profile; + $filtered = UserFilter::whereUserId($p->id) ->whereFilterableType('App\Profile') ->whereIn('filter_type', ['mute', 'block']) ->pluck('filterable_id')->toArray(); + $scope = $p->id == $status->profile_id ? ['public', 'private'] : ['public']; } else { $filtered = []; + $scope = ['public']; } if($request->filled('min_id') || $request->filled('max_id')) { if($request->filled('min_id')) { $replies = $status->comments() ->whereNull('reblog_of_id') + ->whereIn('scope', $scope) ->whereNotIn('profile_id', $filtered) ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') ->where('id', '>=', $request->min_id) @@ -137,6 +140,7 @@ class PublicApiController extends Controller if($request->filled('max_id')) { $replies = $status->comments() ->whereNull('reblog_of_id') + ->whereIn('scope', $scope) ->whereNotIn('profile_id', $filtered) ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') ->where('id', '<=', $request->max_id) @@ -146,6 +150,7 @@ class PublicApiController extends Controller } else { $replies = $status->comments() ->whereNull('reblog_of_id') + ->whereIn('scope', $scope) ->whereNotIn('profile_id', $filtered) ->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at') ->orderBy('id', 'desc')