From a94a3ee06ab234b9279e0a4ba4b254eea2f2aa4b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 19 Jun 2019 13:17:23 -0600 Subject: [PATCH 1/2] Update instances admin view --- resources/views/admin/instances/home.blade.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/views/admin/instances/home.blade.php b/resources/views/admin/instances/home.blade.php index c527eb0b6..32cc867bc 100644 --- a/resources/views/admin/instances/home.blade.php +++ b/resources/views/admin/instances/home.blade.php @@ -13,6 +13,11 @@ Show only Auto CW Show only Banned Show all + +
+ @csrf + +
From 1f1df2d1c4a8779878f8066554c2c6b807ee848e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 19 Jun 2019 13:19:19 -0600 Subject: [PATCH 2/2] Add more rate limits --- app/Util/RateLimit/User.php | 25 +++++++++++++++++++++++++ routes/web.php | 6 +++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/Util/RateLimit/User.php b/app/Util/RateLimit/User.php index d7d51da8f..75e4b1c6e 100644 --- a/app/Util/RateLimit/User.php +++ b/app/Util/RateLimit/User.php @@ -4,6 +4,11 @@ namespace App\Util\RateLimit; trait User { + public function isTrustedAccount() + { + return $this->created_at->lt(now()->subDays(20)); + } + public function getMaxPostsPerHourAttribute() { return 20; @@ -23,4 +28,24 @@ trait User { { return 500; } + + public function getMaxLikesPerHourAttribute() + { + return 120; + } + + public function getMaxLikesPerDayAttribute() + { + return 1000; + } + + public function getMaxSharesPerHourAttribute() + { + return 60; + } + + public function getMaxSharesPerDayAttribute() + { + return 500; + } } \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index fb2c9a56b..d42e34ada 100644 --- a/routes/web.php +++ b/routes/web.php @@ -105,7 +105,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact }); Route::group(['prefix' => 'local'], function () { Route::get('i/follow-suggestions', 'ApiController@followSuggestions'); - Route::post('status/compose', 'InternalApiController@compose'); + Route::post('status/compose', 'InternalApiController@compose')->middleware('throttle:maxPostsPerHour,60')->middleware('throttle:maxPostsPerDay,1440'); Route::get('exp/rec', 'ApiController@userRecommendations'); }); }); @@ -121,8 +121,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::post('unmute', 'AccountController@unmute'); Route::post('block', 'AccountController@block'); Route::post('unblock', 'AccountController@unblock'); - Route::post('like', 'LikeController@store'); - Route::post('share', 'StatusController@storeShare'); + Route::post('like', 'LikeController@store')->middleware('throttle:maxLikesPerHour,60')->middleware('throttle:maxLikesPerDay,1440'); + Route::post('share', 'StatusController@storeShare')->middleware('throttle:maxSharesPerHour,60')->middleware('throttle:maxSharesPerDay,1440'); Route::post('follow', 'FollowerController@store'); Route::post('bookmark', 'BookmarkController@store'); Route::get('lang/{locale}', 'SiteController@changeLocale');