mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 01:05:36 +00:00
Update PublicApiController
This commit is contained in:
parent
cbb786f122
commit
9bbbd11160
1 changed files with 18 additions and 0 deletions
|
@ -19,6 +19,7 @@ use Carbon\Carbon;
|
|||
use League\Fractal;
|
||||
use App\Transformer\Api\{
|
||||
AccountTransformer,
|
||||
RelationshipTransformer,
|
||||
StatusTransformer,
|
||||
};
|
||||
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||
|
@ -330,4 +331,21 @@ class PublicApiController extends Controller
|
|||
return response()->json($res);
|
||||
|
||||
}
|
||||
|
||||
public function relationships(Request $request)
|
||||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
|
||||
$this->validate($request, [
|
||||
'id' => 'required|array|min:1|max:20'
|
||||
]);
|
||||
$ids = collect($request->input('id'));
|
||||
$filtered = $ids->filter(function($v) {
|
||||
return $v != Auth::user()->profile->id;
|
||||
});
|
||||
$relations = Profile::findOrFail($filtered->all());
|
||||
$fractal = new Fractal\Resource\Collection($relations, new RelationshipTransformer());
|
||||
$res = $this->fractal->createData($fractal)->toArray();
|
||||
return response()->json($res);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue