Skip to content

Commit

Permalink
Update AccountController, add followRequestJson method
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Apr 27, 2020
1 parent 996866c commit 483548e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/Http/Controllers/AccountController.php
Expand Up @@ -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, [
Expand Down

0 comments on commit 483548e

Please sign in to comment.