mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-27 02:06:52 +00:00
Update follower counts on follow_request approval
This commit is contained in:
parent
b4dda5776b
commit
e97900a060
2 changed files with 40 additions and 17 deletions
|
@ -398,6 +398,16 @@ class AccountController extends Controller
|
||||||
$follow->following_id = $pid;
|
$follow->following_id = $pid;
|
||||||
$follow->save();
|
$follow->save();
|
||||||
|
|
||||||
|
$profile = Profile::findOrFail($pid);
|
||||||
|
$profile->followers_count++;
|
||||||
|
$profile->save();
|
||||||
|
AccountService::del($profile->id);
|
||||||
|
|
||||||
|
$profile = Profile::findOrFail($follower->id);
|
||||||
|
$profile->following_count++;
|
||||||
|
$profile->save();
|
||||||
|
AccountService::del($profile->id);
|
||||||
|
|
||||||
if($follower->domain != null && $follower->private_key === null) {
|
if($follower->domain != null && $follower->private_key === null) {
|
||||||
FollowAcceptPipeline::dispatch($followRequest);
|
FollowAcceptPipeline::dispatch($followRequest);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1160,18 +1160,21 @@ class ApiV1Controller extends Controller
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'limit' => 'sometimes|integer|min:1|max:40'
|
'limit' => 'sometimes|integer|min:1|max:100'
|
||||||
]);
|
]);
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
|
|
||||||
$followRequests = FollowRequest::whereFollowingId($user->profile->id)
|
$res = FollowRequest::whereFollowingId($user->profile->id)
|
||||||
->limit($request->input('limit', 40))
|
->limit($request->input('limit', 40))
|
||||||
->pluck('follower_id');
|
->pluck('follower_id')
|
||||||
|
->map(function($id) {
|
||||||
|
return AccountService::getMastodon($id, true);
|
||||||
|
})
|
||||||
|
->filter(function($acct) {
|
||||||
|
return $acct && isset($acct['id']);
|
||||||
|
})
|
||||||
|
->values();
|
||||||
|
|
||||||
$profiles = Profile::find($followRequests);
|
|
||||||
|
|
||||||
$resource = new Fractal\Resource\Collection($profiles, new AccountTransformer());
|
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
|
||||||
return $this->json($res);
|
return $this->json($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1204,6 +1207,16 @@ class ApiV1Controller extends Controller
|
||||||
$follow->following_id = $pid;
|
$follow->following_id = $pid;
|
||||||
$follow->save();
|
$follow->save();
|
||||||
|
|
||||||
|
$profile = Profile::findOrFail($pid);
|
||||||
|
$profile->followers_count++;
|
||||||
|
$profile->save();
|
||||||
|
AccountService::del($profile->id);
|
||||||
|
|
||||||
|
$profile = Profile::findOrFail($follower->id);
|
||||||
|
$profile->following_count++;
|
||||||
|
$profile->save();
|
||||||
|
AccountService::del($profile->id);
|
||||||
|
|
||||||
if($follower->domain != null && $follower->private_key === null) {
|
if($follower->domain != null && $follower->private_key === null) {
|
||||||
FollowAcceptPipeline::dispatch($followRequest);
|
FollowAcceptPipeline::dispatch($followRequest);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue