From 483548e217ff46f16cc2e734973fee343dcafc80 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Apr 2020 23:20:27 -0600 Subject: [PATCH] Update AccountController, add followRequestJson method --- app/Http/Controllers/AccountController.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 6f136c3ad5..a554f17d83 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -327,6 +327,27 @@ public function followRequests(Request $request) return view('account.follow-requests', compact('followers')); } + public function followRequestsJson(Request $request) + { + $pid = Auth::user()->profile_id; + $followers = FollowRequest::whereFollowingId($pid)->orderBy('id','desc')->whereIsRejected(0)->get(); + $res = [ + 'count' => $followers->count(), + 'accounts' => $followers->take(10)->map(function($a) { + $actor = $a->actor; + return [ + 'id' => $actor->id, + 'username' => $actor->username, + 'avatar' => $actor->avatarUrl(), + 'url' => $actor->url(), + 'local' => $actor->domain == null, + 'following' => $actor->followedBy(Auth::user()->profile) + ]; + }) + ]; + return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); + } + public function followRequestHandle(Request $request) { $this->validate($request, [