diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 64c37513e..6a814388a 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -309,7 +309,7 @@ class PublicApiController extends Controller ->limit($limit) ->get() ->map(function($s) use ($user) { - $status = StatusService::get($s->id); + $status = StatusService::getFull($s->id, $user->profile_id); $status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id); return $status; }); @@ -341,10 +341,15 @@ class PublicApiController extends Controller ->whereLocal(true) ->whereScope('public') ->orderBy('id', 'desc') - ->simplePaginate($limit); + ->limit($limit) + ->get() + ->map(function($s) use ($user) { + $status = StatusService::getFull($s->id, $user->profile_id); + $status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id); + return $status; + }); - $fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer()); - $res = $this->fractal->createData($fractal)->toArray(); + $res = $timeline->toArray(); } return response()->json($res); diff --git a/app/Services/StatusService.php b/app/Services/StatusService.php index 01d287e8d..2b550a734 100644 --- a/app/Services/StatusService.php +++ b/app/Services/StatusService.php @@ -40,6 +40,13 @@ class StatusService { }); } + public static function getFull($id, $pid, $publicOnly = true) + { + $res = self::get($id, $publicOnly); + $res['relationship'] = RelationshipService::get($pid, $res['account']['id']); + return $res; + } + public static function del($id) { $status = self::get($id);