Refactor following check

pull/5914/head
Daniel Supernault 9 months ago
parent 0f1819125c
commit 8082c004bc
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

File diff suppressed because it is too large Load Diff

@ -788,6 +788,14 @@ class PublicApiController extends Controller
private function determineVisibility($profile, $user)
{
if (! $user || ! isset($user->profile_id)) {
return [];
}
if (! $profile || ! isset($profile['id'])) {
return [];
}
if ($profile['id'] == $user->profile_id) {
return ['public', 'unlisted', 'private'];
}
@ -798,17 +806,13 @@ class PublicApiController extends Controller
}
$pid = $user->profile_id;
$isFollowing = Follower::whereProfileId($pid)
->whereFollowingId($profile['id'])
->exists();
$isFollowing = FollowerService::follows($pid, $profile['id']);
return $isFollowing ? ['public', 'unlisted', 'private'] : ['public'];
} else {
if ($user) {
$pid = $user->profile_id;
$isFollowing = Follower::whereProfileId($pid)
->whereFollowingId($profile['id'])
->exists();
$isFollowing = FollowerService::follows($pid, $profile['id']);
return $isFollowing ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
} else {

Loading…
Cancel
Save