1
0
Fork 0
forked from mirror/pixelfed

Update HomeTimeline api

This commit is contained in:
Daniel Supernault 2021-10-07 04:49:33 -06:00
parent bef959f451
commit e5454620e6
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 16 additions and 4 deletions

View file

@ -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);

View file

@ -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);