Browse Source

Dispatch follow accept/reject pipeline jobs to follow queue

Daniel Supernault 2 năm trước cách đây
mục cha
commit
aaed2bf66e

+ 2 - 2
app/Http/Controllers/AccountController.php

@@ -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();
 				}

+ 4 - 13
app/Http/Controllers/Api/ApiV1Controller.php

@@ -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;