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