From 2a66befa1ac5fde4ed74baecab0ddccd568a8323 Mon Sep 17 00:00:00 2001 From: nanaya Date: Thu, 1 Feb 2024 17:47:25 +0900 Subject: [PATCH 1/2] Adjust score pinning behaviour - only allow passing scores - update preserve flag --- app/Http/Controllers/ScorePinsController.php | 2 ++ app/Libraries/OsuAuthorize.php | 4 ++++ resources/js/core/user/score-pins.ts | 2 +- resources/lang/en/authorization.php | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ScorePinsController.php b/app/Http/Controllers/ScorePinsController.php index 34c3b0ab27c..31b63dd8fae 100644 --- a/app/Http/Controllers/ScorePinsController.php +++ b/app/Http/Controllers/ScorePinsController.php @@ -100,6 +100,8 @@ public function store() throw $ex; } } + + $score->update(['preserve' => true]); } return response()->noContent(); diff --git a/app/Libraries/OsuAuthorize.php b/app/Libraries/OsuAuthorize.php index acfb5d97a9f..33f5ef0903e 100644 --- a/app/Libraries/OsuAuthorize.php +++ b/app/Libraries/OsuAuthorize.php @@ -1937,6 +1937,10 @@ public function checkScorePin(?User $user, ScoreBest|Solo\Score $score): string return $prefix.'not_owner'; } + if (!$score->passed) { + return $prefix.'failed'; + } + if ($score instanceof Solo\Score && $GLOBALS['cfg']['osu']['user']['hide_pinned_solo_scores']) { return $prefix.'disabled_type'; } diff --git a/resources/js/core/user/score-pins.ts b/resources/js/core/user/score-pins.ts index 77ca6e334c9..61caf87bc80 100644 --- a/resources/js/core/user/score-pins.ts +++ b/resources/js/core/user/score-pins.ts @@ -30,7 +30,7 @@ export default class ScorePins { } canBePinned(score: SoloScoreJson) { - return score.current_user_attributes.pin != null; + return score.current_user_attributes.pin != null && score.passed; } isPinned(score: SoloScoreJson) { diff --git a/resources/lang/en/authorization.php b/resources/lang/en/authorization.php index 1db30df9de9..804f05c1cc7 100644 --- a/resources/lang/en/authorization.php +++ b/resources/lang/en/authorization.php @@ -173,6 +173,7 @@ 'score' => [ 'pin' => [ 'disabled_type' => "Can't pin this type of score", + 'failed' => "Can't pin non-passing score.", 'not_owner' => 'Only score owner can pin score.', 'too_many' => 'Pinned too many scores.', ], From 5430f0503681ff868d060dffe0e53c1c8f050a4f Mon Sep 17 00:00:00 2001 From: nanaya Date: Thu, 1 Feb 2024 18:08:50 +0900 Subject: [PATCH 2/2] Only for lazer scores --- app/Http/Controllers/ScorePinsController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ScorePinsController.php b/app/Http/Controllers/ScorePinsController.php index 31b63dd8fae..3270bfdd568 100644 --- a/app/Http/Controllers/ScorePinsController.php +++ b/app/Http/Controllers/ScorePinsController.php @@ -9,6 +9,7 @@ use App\Libraries\MorphMap; use App\Models\Beatmap; use App\Models\ScorePin; +use App\Models\Solo; use Exception; class ScorePinsController extends Controller @@ -101,7 +102,9 @@ public function store() } } - $score->update(['preserve' => true]); + if ($score instanceof Solo\Score) { + $score->update(['preserve' => true]); + } } return response()->noContent();