From fb40a55c7c2ad3ca73a47f8b78d9155aafb1a1eb Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Feb 2019 21:30:02 -0700 Subject: [PATCH 1/3] Add new api routes --- app/Http/Controllers/PublicApiController.php | 17 +++++++++++++---- routes/web.php | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 3a2685021..510b15717 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -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); } + } diff --git a/routes/web.php b/routes/web.php index 13245e394..89434be7b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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'); From 838cca12b562f335cf1b6237ea9e863fb6a67f1f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Feb 2019 22:04:01 -0700 Subject: [PATCH 2/3] Update Profile component --- resources/assets/js/components/Profile.vue | 137 ++++++++++++++++++++- 1 file changed, 134 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/components/Profile.vue b/resources/assets/js/components/Profile.vue index 76c36a120..dddb4ef77 100644 --- a/resources/assets/js/components/Profile.vue +++ b/resources/assets/js/components/Profile.vue @@ -39,13 +39,13 @@
- + {{profile.following_count}} Following @@ -223,6 +223,64 @@ + +
+
+
+ + + +
+

+ + {{user.username}} + +

+

+ {{user.display_name}} +

+
+
+
+
+

Load more

+
+
+
+ +
+
+
+ + + +
+

+ + {{user.username}} + +

+

+ {{user.display_name}} +

+
+
+
+
+

Load more

+
+
+