Update PublicApiController

This commit is contained in:
Daniel Supernault 2021-12-04 20:41:46 -07:00
parent fe64e18712
commit 2923453e13
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -27,6 +27,7 @@ use App\Transformer\Api\{
};
use App\Services\{
AccountService,
FollowerService,
LikeService,
PublicTimelineService,
ProfileService,
@ -151,13 +152,8 @@ class PublicApiController extends Controller
if(Auth::check()) {
$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', 'unlisted'] : ['public','unlisted'];
$scope = $p->id == $status->profile_id || FollowerService::follows($p->id, $profile->id) ? ['public', 'private', 'unlisted'] : ['public','unlisted'];
} else {
$filtered = [];
$scope = ['public', 'unlisted'];
}
@ -166,7 +162,6 @@ class PublicApiController extends Controller
$replies = $status->comments()
->whereNull('reblog_of_id')
->whereIn('scope', $scope)
->whereNotIn('profile_id', $filtered)
->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->where('id', '>=', $request->min_id)
->orderBy('id', 'desc')
@ -176,17 +171,15 @@ class PublicApiController extends Controller
$replies = $status->comments()
->whereNull('reblog_of_id')
->whereIn('scope', $scope)
->whereNotIn('profile_id', $filtered)
->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->where('id', '<=', $request->max_id)
->orderBy('id', 'desc')
->paginate($limit);
}
} else {
$replies = $status->comments()
$replies = Status::whereInReplyToId($status->id)
->whereNull('reblog_of_id')
->whereIn('scope', $scope)
->whereNotIn('profile_id', $filtered)
->select('id', 'caption', 'local', 'visibility', 'scope', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
->orderBy('id', 'desc')
->paginate($limit);
@ -438,6 +431,7 @@ class PublicApiController extends Controller
$filtered = $user ? UserFilterService::filters($user->profile_id) : [];
$types = ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'];
// $types = ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album', 'text'];
$textOnlyReplies = false;