mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-18 20:41:27 +00:00
Merge pull request #4687 from pixelfed/staging
Update ApiV1Controller, hydrate reblog interactions. Fixes #4686
This commit is contained in:
commit
d679ae4f11
1 changed files with 12 additions and 6 deletions
|
@ -2507,7 +2507,7 @@ class ApiV1Controller extends Controller
|
|||
{
|
||||
abort_if(!$request->user(), 403);
|
||||
|
||||
$user = $request->user();
|
||||
$pid = $request->user()->profile_id;
|
||||
|
||||
$res = $request->has(self::PF_API_ENTITY_KEY) ? StatusService::get($id, false) : StatusService::getMastodon($id, false);
|
||||
if(!$res || !isset($res['visibility'])) {
|
||||
|
@ -2517,17 +2517,23 @@ class ApiV1Controller extends Controller
|
|||
$scope = $res['visibility'];
|
||||
if(!in_array($scope, ['public', 'unlisted'])) {
|
||||
if($scope === 'private') {
|
||||
if(intval($res['account']['id']) !== intval($user->profile_id)) {
|
||||
abort_unless(FollowerService::follows($user->profile_id, $res['account']['id']), 403);
|
||||
if(intval($res['account']['id']) !== intval($pid)) {
|
||||
abort_unless(FollowerService::follows($pid, $res['account']['id']), 403);
|
||||
}
|
||||
} else {
|
||||
abort(400, 'Invalid request');
|
||||
}
|
||||
}
|
||||
|
||||
$res['favourited'] = LikeService::liked($user->profile_id, $res['id']);
|
||||
$res['reblogged'] = ReblogService::get($user->profile_id, $res['id']);
|
||||
$res['bookmarked'] = BookmarkService::get($user->profile_id, $res['id']);
|
||||
if(!empty($res['reblog']) && isset($res['reblog']['id'])) {
|
||||
$res['reblog']['favourited'] = (bool) LikeService::liked($pid, $res['reblog']['id']);
|
||||
$res['reblog']['reblogged'] = (bool) ReblogService::get($pid, $res['reblog']['id']);
|
||||
$res['reblog']['bookmarked'] = BookmarkService::get($pid, $res['reblog']['id']);
|
||||
}
|
||||
|
||||
$res['favourited'] = LikeService::liked($pid, $res['id']);
|
||||
$res['reblogged'] = ReblogService::get($pid, $res['id']);
|
||||
$res['bookmarked'] = BookmarkService::get($pid, $res['id']);
|
||||
|
||||
return $this->json($res);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue