Skip to content

Commit

Permalink
Merge pull request #11607 from nanaya/follow-limit
Browse files Browse the repository at this point in the history
Limit maximum number of mappers that can be followed
  • Loading branch information
notbakaneko authored Oct 31, 2024
2 parents b347c2f + de75888 commit 346cacb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ CLIENT_CHECK_VERSION=false
# space delimited, list of groups (the identifier) which user can be renamed when inactive
# USER_ALLOWED_RENAME_GROUPS="default"

# USER_MAX_FOLLOWS=5000
# USER_MAX_FRIENDS=250
# USER_MAX_FRIENDS_SUPPORTER=500
# USER_MAX_MULTIPLAYER_DURATION=14
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/FollowsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public function index($subtype = null)

public function store()
{
if (\Auth::user()->follows()->count() >= $GLOBALS['cfg']['osu']['user']['max_follows']) {
return error_popup(osu_trans('follows.store.too_many'));
}
$params = $this->getParams();
$follow = new Follow($params);

Expand All @@ -89,7 +92,7 @@ public function store()
dispatch(new UpdateUserMappingFollowerCountCache($params['notifiable_id']));
}

return response([], 204);
return response(null, 204);
}

private function getParams()
Expand Down
1 change: 1 addition & 0 deletions config/osu.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
'user_page_forum_id' => intval(env('USER_PAGE_FORUM_ID', 70)),
'verification_key_length_hex' => 8,
'verification_key_tries_limit' => 8,
'max_follows' => get_int(env('USER_MAX_FOLLOWS')) ?? 5000,
'max_friends' => get_int(env('USER_MAX_FRIENDS')) ?? 250,
'max_friends_supporter' => get_int(env('USER_MAX_FRIENDS_SUPPORTER')) ?? 500,
'max_login_attempts' => get_int(env('USER_MAX_LOGIN_ATTEMPTS')) ?? 10,
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en/follows.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@
'modding' => [
'title' => 'beatmap discussion',
],

'store' => [
'too_many' => 'Follow limit reached.',
],
];

0 comments on commit 346cacb

Please sign in to comment.