Merge pull request #3936 from pixelfed/staging

Dispatch follow accept/reject pipeline jobs to follow queue
This commit is contained in:
daniel 2022-12-12 20:45:13 -07:00 committed by GitHub
commit 5ec8bc7d98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 15 deletions

View file

@ -409,7 +409,7 @@ class AccountController extends Controller
AccountService::del($profile->id);
if($follower->domain != null && $follower->private_key === null) {
FollowAcceptPipeline::dispatch($followRequest);
FollowAcceptPipeline::dispatch($followRequest)->onQueue('follow');
} else {
FollowPipeline::dispatch($follow);
$followRequest->delete();
@ -418,7 +418,7 @@ class AccountController extends Controller
case 'reject':
if($follower->domain != null && $follower->private_key === null) {
FollowRejectPipeline::dispatch($followRequest);
FollowRejectPipeline::dispatch($followRequest)->onQueue('follow');
} else {
$followRequest->delete();
}

View file

@ -673,15 +673,10 @@ class ApiV1Controller extends Controller
}
// Rate limits, max 7500 followers per account
if($user->profile->following()->count() >= Follower::MAX_FOLLOWING) {
if($user->profile->following_count && $user->profile->following_count >= Follower::MAX_FOLLOWING) {
abort(400, 'You cannot follow more than ' . Follower::MAX_FOLLOWING . ' accounts');
}
// Rate limits, follow 30 accounts per hour max
if($user->profile->following()->where('followers.created_at', '>', now()->subHour())->count() >= Follower::FOLLOW_PER_HOUR) {
abort(400, 'You can only follow ' . Follower::FOLLOW_PER_HOUR . ' users per hour');
}
if($private == true) {
$follow = FollowRequest::firstOrCreate([
'follower_id' => $user->profile_id,
@ -761,11 +756,6 @@ class ApiV1Controller extends Controller
return $this->json($res);
}
// Rate limits, follow 30 accounts per hour max
if($user->profile->following()->where('followers.updated_at', '>', now()->subHour())->count() >= Follower::FOLLOW_PER_HOUR) {
abort(400, 'You can only follow or unfollow ' . Follower::FOLLOW_PER_HOUR . ' users per hour');
}
if($user->profile->following_count) {
$user->profile->decrement('following_count');
}
@ -1266,7 +1256,7 @@ class ApiV1Controller extends Controller
AccountService::del($profile->id);
if($follower->domain != null && $follower->private_key === null) {
FollowAcceptPipeline::dispatch($followRequest);
FollowAcceptPipeline::dispatch($followRequest)->onQueue('follow');
} else {
FollowPipeline::dispatch($follow);
$followRequest->delete();
@ -1304,7 +1294,7 @@ class ApiV1Controller extends Controller
$follower = $followRequest->follower;
if($follower->domain != null && $follower->private_key === null) {
FollowRejectPipeline::dispatch($followRequest);
FollowRejectPipeline::dispatch($followRequest)->onQueue('follow');
} else {
$followRequest->delete();
}
@ -2511,6 +2501,7 @@ class ApiV1Controller extends Controller
$ids = $request->input('media_ids');
$in_reply_to_id = $request->input('in_reply_to_id');
$user = $request->user();
$profile = $user->profile;