Skip to content

Commit

Permalink
Update ApiV1Controller, add pe (pixelfed entity) support to /api/v1/s…
Browse files Browse the repository at this point in the history
…tatuses/{id}/context endpoint
  • Loading branch information
dansup committed May 11, 2024
1 parent 29e472d commit d645d6c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Http/Controllers/Api/ApiV1Controller.php
Expand Up @@ -3020,9 +3020,9 @@ public function statusContext(Request $request, $id)
abort_unless($request->user()->tokenCan('read'), 403);

$user = $request->user();
AccountService::setLastActive($user->id);
$pid = $user->profile_id;
$status = StatusService::getMastodon($id, false);
$pe = $request->has(self::PF_API_ENTITY_KEY);

if (! $status || ! isset($status['account'])) {
return response('', 404);
Expand All @@ -3049,7 +3049,9 @@ public function statusContext(Request $request, $id)
$descendants = [];

if ($status['in_reply_to_id']) {
$ancestors[] = StatusService::getMastodon($status['in_reply_to_id'], false);
$ancestors[] = $pe ?
StatusService::get($status['in_reply_to_id'], false) :
StatusService::getMastodon($status['in_reply_to_id'], false);
}

if ($status['replies_count']) {
Expand All @@ -3059,8 +3061,10 @@ public function statusContext(Request $request, $id)
->where('in_reply_to_id', $id)
->limit(20)
->pluck('id')
->map(function ($sid) {
return StatusService::getMastodon($sid, false);
->map(function ($sid) use ($pe) {
return $pe ?
StatusService::get($sid, false) :
StatusService::getMastodon($sid, false);
})
->filter(function ($post) use ($filters) {
return $post && isset($post['account'], $post['account']['id']) && ! in_array($post['account']['id'], $filters);
Expand Down

0 comments on commit d645d6c

Please sign in to comment.