Skip to content

Commit

Permalink
Merge pull request ppy#10943 from nanaya/pin-pass
Browse files Browse the repository at this point in the history
Adjust score pinning behaviour
  • Loading branch information
notbakaneko authored Feb 1, 2024
2 parents 0f0b689 + 6f29aef commit 1055da3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/Http/Controllers/ScorePinsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,6 +101,10 @@ public function store()
throw $ex;
}
}

if ($score instanceof Solo\Score) {
$score->update(['preserve' => true]);
}
}

return response()->noContent();
Expand Down
4 changes: 4 additions & 0 deletions app/Libraries/OsuAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/core/user/score-pins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
],
Expand Down

0 comments on commit 1055da3

Please sign in to comment.