1
0
Fork 0
forked from mirror/pixelfed

Update PublicApiController, add LikeService to Network timeline

This commit is contained in:
Daniel Supernault 2021-07-02 01:34:35 -06:00
parent d3157f2a2d
commit 82895591c3
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -26,6 +26,7 @@ use App\Transformer\Api\{
}; };
use App\Services\{ use App\Services\{
AccountService, AccountService,
LikeService,
PublicTimelineService, PublicTimelineService,
StatusService, StatusService,
SnowflakeService, SnowflakeService,
@ -527,8 +528,10 @@ class PublicApiController extends Controller
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->limit($limit) ->limit($limit)
->get() ->get()
->map(function($s) { ->map(function($s) use ($user) {
return StatusService::get($s->id); $status = StatusService::get($s->id);
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id);
return $status;
}); });
$res = $timeline->toArray(); $res = $timeline->toArray();
} else { } else {
@ -545,8 +548,10 @@ class PublicApiController extends Controller
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->limit($limit) ->limit($limit)
->get() ->get()
->map(function($s) { ->map(function($s) use ($user) {
return StatusService::get($s->id); $status = StatusService::get($s->id);
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id);
return $status;
}); });
$res = $timeline->toArray(); $res = $timeline->toArray();
} }