1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2025-03-03 18:25:47 +00:00

Update PublicApiController, use AccountService in accountStatuses method

This commit is contained in:
Daniel Supernault 2021-10-07 03:30:23 -06:00
parent 80d9b9399a
commit bef959f451
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -676,14 +676,15 @@ class PublicApiController extends Controller
]); ]);
$user = $request->user(); $user = $request->user();
$profile = Profile::whereNull('status')->findOrFail($id); $profile = AccountService::get($id);
abort_if(!$profile, 404);
$limit = $request->limit ?? 9; $limit = $request->limit ?? 9;
$max_id = $request->max_id; $max_id = $request->max_id;
$min_id = $request->min_id; $min_id = $request->min_id;
$scope = ['photo', 'photo:album', 'video', 'video:album']; $scope = ['photo', 'photo:album', 'video', 'video:album'];
if($profile->is_private) { if($profile['locked']) {
if(!$user) { if(!$user) {
return response()->json([]); return response()->json([]);
} }
@ -700,7 +701,7 @@ class PublicApiController extends Controller
$following = Follower::whereProfileId($pid)->pluck('following_id'); $following = Follower::whereProfileId($pid)->pluck('following_id');
return $following->push($pid)->toArray(); return $following->push($pid)->toArray();
}); });
$visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : ['public', 'unlisted']; $visibility = true == in_array($profile['id'], $following) ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
} else { } else {
$visibility = ['public', 'unlisted']; $visibility = ['public', 'unlisted'];
} }
@ -708,15 +709,7 @@ class PublicApiController extends Controller
$dir = $min_id ? '>' : '<'; $dir = $min_id ? '>' : '<';
$id = $min_id ?? $max_id; $id = $min_id ?? $max_id;
$res = Status::select( $res = Status::whereProfileId($profile['id'])
'id',
'profile_id',
'type',
'scope',
'local',
'created_at'
)
->whereProfileId($profile->id)
->whereNull('in_reply_to_id') ->whereNull('in_reply_to_id')
->whereNull('reblog_of_id') ->whereNull('reblog_of_id')
->whereIn('type', $scope) ->whereIn('type', $scope)