1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-25 17:26:43 +00:00

Update PublicApiController

This commit is contained in:
Daniel Supernault 2019-02-10 13:42:26 -07:00
parent cbb786f122
commit 9bbbd11160
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -19,6 +19,7 @@ use Carbon\Carbon;
use League\Fractal; use League\Fractal;
use App\Transformer\Api\{ use App\Transformer\Api\{
AccountTransformer, AccountTransformer,
RelationshipTransformer,
StatusTransformer, StatusTransformer,
}; };
use App\Jobs\StatusPipeline\NewStatusPipeline; use App\Jobs\StatusPipeline\NewStatusPipeline;
@ -330,4 +331,21 @@ class PublicApiController extends Controller
return response()->json($res); 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);
}
} }