mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Add new api routes
This commit is contained in:
parent
77c056e93b
commit
fb40a55c7c
2 changed files with 15 additions and 4 deletions
|
@ -395,8 +395,12 @@ class PublicApiController extends Controller
|
|||
|
||||
public function accountFollowers(Request $request, $id)
|
||||
{
|
||||
$profile = Profile::findOrFail($id);
|
||||
$followers = $profile->followers;
|
||||
abort_unless(Auth::check(), 403);
|
||||
$profile = Profile::with('user')->whereNull('status')->whereNull('domain')->findOrFail($id);
|
||||
if($profile->is_private || !$profile->user->settings->show_profile_followers) {
|
||||
return [];
|
||||
}
|
||||
$followers = $profile->followers()->orderByDesc('followers.created_at')->paginate(10);
|
||||
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
|
||||
|
@ -405,8 +409,12 @@ class PublicApiController extends Controller
|
|||
|
||||
public function accountFollowing(Request $request, $id)
|
||||
{
|
||||
$profile = Profile::findOrFail($id);
|
||||
$following = $profile->following;
|
||||
abort_unless(Auth::check(), 403);
|
||||
$profile = Profile::with('user')->whereNull('status')->whereNull('domain')->findOrFail($id);
|
||||
if($profile->is_private || !$profile->user->settings->show_profile_following) {
|
||||
return [];
|
||||
}
|
||||
$following = $profile->following()->orderByDesc('followers.created_at')->paginate(10);
|
||||
$resource = new Fractal\Resource\Collection($following, new AccountTransformer());
|
||||
$res = $this->fractal->createData($resource)->toArray();
|
||||
|
||||
|
@ -468,4 +476,5 @@ class PublicApiController extends Controller
|
|||
|
||||
return response()->json($res);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,6 +70,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
|||
Route::get('accounts/verify_credentials', 'ApiController@verifyCredentials');
|
||||
Route::get('accounts/relationships', 'PublicApiController@relationships');
|
||||
Route::get('accounts/{id}/statuses', 'PublicApiController@accountStatuses');
|
||||
Route::get('accounts/{id}/following', 'PublicApiController@accountFollowing');
|
||||
Route::get('accounts/{id}/followers', 'PublicApiController@accountFollowers');
|
||||
Route::get('accounts/{id}', 'PublicApiController@account');
|
||||
Route::post('avatar/update', 'ApiController@avatarUpdate');
|
||||
Route::get('likes', 'ApiController@hydrateLikes');
|
||||
|
|
Loading…
Reference in a new issue