Update ApiV1Controller, add status ancestor and descendant context

This commit is contained in:
Daniel Supernault 2020-06-18 21:03:35 -06:00
parent 16e55b0cae
commit a0bde855bd
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 21 additions and 5 deletions

View File

@ -1525,11 +1525,27 @@ class ApiV1Controller extends Controller
} }
} }
// Return empty response since we don't handle threading like this if($status->comments_disabled) {
$res = [ $res = [
'ancestors' => [], 'ancestors' => [],
'descendants' => [] 'descendants' => []
]; ];
} else {
$ancestors = $status->parent();
if($ancestors) {
$ares = new Fractal\Resource\Item($ancestors, new StatusTransformer());
$ancestors = $this->fractal->createData($ares)->toArray();
} else {
$ancestors = [];
}
$descendants = Status::whereInReplyToId($id)->latest()->limit(20)->get();
$dres = new Fractal\Resource\Collection($descendants, new StatusTransformer());
$descendants = $this->fractal->createData($dres)->toArray();
$res = [
'ancestors' => $ancestors,
'descendants' => $descendants
];
}
return response()->json($res); return response()->json($res);
} }