Skip to content

Commit

Permalink
Merge branch 'master' into get-params-null
Browse files Browse the repository at this point in the history
  • Loading branch information
notbakaneko authored Oct 3, 2024
2 parents 7c73b1c + 782c046 commit 192db7b
Show file tree
Hide file tree
Showing 63 changed files with 153 additions and 246 deletions.
84 changes: 5 additions & 79 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,12 @@

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\DbCreate::class,
Commands\DbSetup::class,

Commands\EsCreateSearchBlacklist::class,
Commands\EsIndexDocuments::class,
Commands\EsIndexScoresQueue::class,
Commands\EsIndexScoresSetSchema::class,
Commands\EsIndexWiki::class,

Commands\Ip2AsnUpdate::class,

// modding stuff
Commands\ModdingRankCommand::class,

Commands\UserForumStatSyncCommand::class,
Commands\BeatmapsetsHypeSyncCommand::class,
Commands\BeatmapsetNominationSyncCommand::class,

Commands\StoreCleanupStaleOrders::class,
Commands\StoreExpireProducts::class,
Commands\StoreGetPaypalOrder::class,
Commands\StoreGetShopifyCheckout::class,

// builds
Commands\BuildsCreate::class,
Commands\BuildsUpdatePropagationHistory::class,

// forum
Commands\ForumTopicCoversCleanup::class,

// leaderboard recalculation
Commands\RankingsRecalculateCountryStats::class,

// moddingv2 kudosu recalculation
Commands\KudosuRecalculateDiscussionsGrants::class,

// fix username change fail :D
Commands\FixUsernameChangeTopicCache::class,

// fix userchannel deletion fail
Commands\FixMissingUserChannels::class,

// fix forum display order
Commands\FixForumDisplayOrder::class,

Commands\MigrateFreshAllCommand::class,
Commands\MigrateFreshOrRunCommand::class,

Commands\NotificationsSendMail::class,

Commands\OAuthDeleteExpiredTokens::class,

Commands\RouteConvert::class,

Commands\UserBestScoresCheckCommand::class,
Commands\UserRecalculateRankCounts::class,

Commands\UserNotificationsCleanup::class,
Commands\NotificationsCleanup::class,

Commands\ChatExpireAck::class,
Commands\ChatChannelSetLastMessageId::class,

Commands\BeatmapLeadersRefresh::class,
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

Commands\DailyChallengeCreateNext::class,
Commands\DailyChallengeUserStatsCalculate::class,
Commands\DailyChallengeUserStatsRecalculate::class,
];
require base_path('routes/console.php');
}

/**
* Define the application's command schedule.
Expand Down Expand Up @@ -152,9 +83,4 @@ protected function schedule(Schedule $schedule)
->cron('10 0 * * *')
->onOneServer();
}

protected function commands()
{
require base_path('routes/console.php');
}
}
5 changes: 4 additions & 1 deletion app/Http/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ public function __construct()
'updateOptions',
]]);

$this->middleware('throttle:60,10', ['only' => [
$this->middleware('throttle:3,5', ['only' => [
'reissueCode',
]]);

$this->middleware('throttle:60,10', ['only' => [
'updateEmail',
'updatePassword',
'verify',
Expand Down
2 changes: 1 addition & 1 deletion app/Libraries/SessionVerification/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class State
{
private const KEY_VALID_DURATION = 5 * 3600;
private const KEY_VALID_DURATION = 600;

public readonly CarbonImmutable $expiresAt;
public readonly string $key;
Expand Down
4 changes: 2 additions & 2 deletions app/Libraries/User/PasswordResetData.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ private function __construct(
$this->cacheKey = static::cacheKey($this->user, $username);
}

public static function create(?User $user, string $username): ?string
public static function create(?User $user, ?string $username): ?string
{
if ($user === null) {
if ($user === null || $username === null) {
return osu_trans('password_reset.error.user_not_found');
}

Expand Down
8 changes: 1 addition & 7 deletions app/Models/BeatmapDiscussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ class BeatmapDiscussion extends Model
// FIXME: This and other static search functions should be extracted out.
public static function search($rawParams = [])
{
$pagination = pagination(cursor_from_params($rawParams) ?? $rawParams);
[$query, $params] = static::searchQueryAndParams(cursor_from_params($rawParams) ?? $rawParams);

$params = [
'limit' => $pagination['limit'],
'page' => $pagination['page'],
];

$query = static::limit($params['limit'])->offset($pagination['offset']);
$isModerator = $rawParams['is_moderator'] ?? false;

if (present($rawParams['user'] ?? null)) {
Expand Down
8 changes: 1 addition & 7 deletions app/Models/BeatmapDiscussionPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,8 @@ class BeatmapDiscussionPost extends Model implements Traits\ReportableInterface

public static function search($rawParams = [])
{
$pagination = pagination(cursor_from_params($rawParams) ?? $rawParams);
[$query, $params] = static::searchQueryAndParams(cursor_from_params($rawParams) ?? $rawParams);

$params = [
'limit' => $pagination['limit'],
'page' => $pagination['page'],
];

$query = static::limit($params['limit'])->offset($pagination['offset']);
$isModerator = $rawParams['is_moderator'] ?? false;

if (isset($rawParams['user'])) {
Expand Down
8 changes: 1 addition & 7 deletions app/Models/BeatmapDiscussionVote.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ public static function recentlyGivenByUser($userId, $timeframeMonths = 3)

public static function search($rawParams = [])
{
$pagination = pagination(cursor_from_params($rawParams) ?? $rawParams);
[$query, $params] = static::searchQueryAndParams(cursor_from_params($rawParams) ?? $rawParams);

$params = [
'limit' => $pagination['limit'],
'page' => $pagination['page'],
];

$query = static::limit($params['limit'])->offset($pagination['offset']);
$isModerator = $rawParams['is_moderator'] ?? false;

if (isset($rawParams['user'])) {
Expand Down
8 changes: 1 addition & 7 deletions app/Models/BeatmapsetEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,8 @@ public static function log($type, $user, $object, $extraData = [])

public static function search($rawParams = [])
{
$pagination = pagination($rawParams);
[$query, $params] = static::searchQueryAndParams($rawParams);

$params = [
'limit' => $pagination['limit'],
'page' => $pagination['page'],
];

$query = static::limit($params['limit'])->offset($pagination['offset']);
$searchByUser = present($rawParams['user'] ?? null);
$isModerator = $rawParams['is_moderator'] ?? false;

Expand Down
13 changes: 13 additions & 0 deletions app/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ public static function booted()
static::addGlobalScope(new MacroableModelScope());
}

protected static function searchQueryAndParams(array $params)
{
$limit = clamp(get_int($params['limit'] ?? null) ?? static::PER_PAGE, 5, 50);
$page = max(get_int($params['page'] ?? null), 1);

$offset = max_offset($page, $limit);
$page = 1 + $offset / $limit;

$query = static::limit($limit)->offset($offset);

return [$query, compact('limit', 'page')];
}

public function getForeignKey()
{
if ($this->primaryKey === null || $this->primaryKey === 'id') {
Expand Down
2 changes: 1 addition & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class User extends Model implements AfterCommit, AuthenticatableContract, HasLoc

const MAX_FIELD_LENGTHS = [
'user_discord' => 37, // max 32char username + # + 4-digit discriminator
'user_from' => 30,
'user_from' => 25,
'user_interests' => 30,
'user_occ' => 30,
'user_sig' => 3000,
Expand Down
2 changes: 1 addition & 1 deletion app/Singletons/OsuAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ public function checkChatAnnounce(?User $user): string
return 'ok';
}

return $prefix.'annnonce_only';
return $prefix.'no_announce';
}

/**
Expand Down
11 changes: 0 additions & 11 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,17 +651,6 @@ function pack_str($str)
return pack('ccH*', 0x0b, strlen($str), bin2hex($str));
}

function pagination($params, $defaults = null)
{
$limit = clamp(get_int($params['limit'] ?? null) ?? $defaults['limit'] ?? 20, 5, 50);
$page = max(get_int($params['page'] ?? null) ?? 1, 1);

$offset = max_offset($page, $limit);
$page = 1 + $offset / $limit;

return compact('limit', 'page', 'offset');
}

function product_quantity_options($product, $selected = null)
{
if ($product->stock === null) {
Expand Down
2 changes: 1 addition & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function definition(): array
'user_interests' => fn () => mb_substr($this->faker->bs(), 0, 30),
'user_occ' => fn () => mb_substr($this->faker->catchPhrase(), 0, 30),
'user_sig' => fn () => $this->faker->realText(155),
'user_from' => fn () => mb_substr($this->faker->country(), 0, 30),
'user_from' => fn () => mb_substr($this->faker->country(), 0, 25),
'user_regdate' => fn () => $this->faker->dateTimeBetween('-6 years'),
];
}
Expand Down
4 changes: 2 additions & 2 deletions resources/lang/be/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@

'download' => [
'action' => 'Спампаваць osu!',
'action_lazer' => 'Скачаць osu!(lazer)',
'action_lazer' => 'Спампаваць osu!(lazer)',
'action_lazer_description' => 'наступнае глабальнае абнаўленне osu!',
'action_lazer_info' => 'артыкул з падрабязнай інфармацыяй',
'action_lazer_title' => 'паспрабаваць osu!(lazer)',
'action_title' => 'скачаць osu!',
'action_title' => 'спампаваць osu!',
'for_os' => 'для :os',
'macos-fallback' => 'для macOS',
'mirror' => 'люстэрка',
Expand Down
14 changes: 7 additions & 7 deletions resources/lang/bg/beatmaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
'message_placeholder_locked' => 'Изключена е дискусията за този бийтмап.',
'message_placeholder_silenced' => "Не може да публикувате дискусии, докато сте заглушени.",
'message_type_select' => 'Избор на вид коментар',
'reply_notice' => 'Натисни enter за отговор.',
'reply_notice' => 'Натиснете enter, за да отговорите.',
'reply_resolve_notice' => '',
'reply_placeholder' => 'Въведете вашия отговор тук',
'require-login' => 'Моля, влез в профила си, за публикуване или отговор',
'resolved' => 'Приключен',
'require-login' => 'Моля, влезте в профила си, за да публикувате или отговаряте',
'resolved' => 'Разрешени',
'restore' => 'възстанови',
'show_deleted' => 'Покажи изтрити',
'title' => 'Дискусии',
Expand All @@ -46,13 +46,13 @@

'lock' => [
'button' => [
'lock' => 'Заключи дискусия',
'unlock' => 'Отключи дискусия',
'lock' => 'Заключи дискусията',
'unlock' => 'Отключи дискусията',
],

'prompt' => [
'lock' => 'Причина за заключване',
'unlock' => 'Наистина ли искате да отключите?',
'lock' => 'Причина за заключването',
'unlock' => 'Сигурни ли сте, че искате да отключите дискусията?',
],
],

Expand Down
2 changes: 1 addition & 1 deletion resources/lang/cs/beatmapsets.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

'dialog' => [
'confirmation' => 'Jste si jisti, že chcete nominovat tuto beatmapu?',
'different_nominator_warning' => '',
'different_nominator_warning' => 'Kvalifikace této beatmapy s jinými nominátory vyresetuje její pozici ve frontě kvalifikací.',
'header' => 'Nominovat beatmapu',
'hybrid_warning' => 'poznámka: můžete nominovat pouze jednou, takže se ujistěte, že nominujete za všechny herní režimy, které chcete',
'current_main_ruleset' => 'Hlavní ruleset je aktuálně: :ruleset',
Expand Down
8 changes: 4 additions & 4 deletions resources/lang/cs/rankings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
],

'daily_challenge' => [
'beatmap' => '',
'percentile_10' => '',
'percentile_50' => '',
'beatmap' => 'Obtížnost',
'percentile_10' => 'Skóre 10. percentilu',
'percentile_50' => 'Skóre 50. percentilu',
],

'filter' => [
Expand All @@ -36,7 +36,7 @@
'type' => [
'charts' => 'výběry (staré)',
'country' => 'stát',
'daily_challenge' => '',
'daily_challenge' => 'denní výzva',
'kudosu' => 'kudosu',
'multiplayer' => 'hra pro více hráčů',
'performance' => 'výkon',
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/de/accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
'beatmapset_disqualify' => 'Erhalte Benachrichtigungen, wenn Beatmaps der folgenden Modi disqualifiziert werden',
'comment_reply' => 'Erhalte Benachrichtigungen für Antworten auf deine Kommentare',
'title' => 'Benachrichtigungen',
'topic_auto_subscribe' => 'Benachrichtigungen zu den von dir erstellten Forenposts immer aktivieren',
'topic_auto_subscribe' => 'Benachrichtigungen zu den Forenposts, die du erstellt oder auf die du geantwortet hast, immer aktivieren',

'options' => [
'_' => 'Zustelloptionen',
Expand Down
8 changes: 4 additions & 4 deletions resources/lang/de/rankings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
],

'daily_challenge' => [
'beatmap' => '',
'percentile_10' => '',
'percentile_50' => '',
'beatmap' => 'Level',
'percentile_10' => 'Punktzahl im 10ten Perzentil',
'percentile_50' => 'Median',
],

'filter' => [
Expand All @@ -36,7 +36,7 @@
'type' => [
'charts' => 'Spotlights (alt)',
'country' => 'Länder',
'daily_challenge' => '',
'daily_challenge' => 'Tägliche Herausforderung',
'kudosu' => 'Kudosu',
'multiplayer' => 'Mehrspieler',
'performance' => 'Performance',
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/en/authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
],

'chat' => [
'annnonce_only' => 'This channel is for announcements only.',
'blocked' => 'Cannot message a user that is blocking you or that you have blocked.',
'friends_only' => 'User is blocking messages from people not on their friends list.',
'moderated' => 'This channel is currently moderated.',
'no_access' => 'You do not have access to that channel.',
'no_announce' => 'You do not have permission to post announcement.',
'receive_friends_only' => 'The user may not be able to reply because you are only accepting messages from people on your friends list.',
'restricted' => 'You cannot send messages while silenced, restricted or banned.',
'silenced' => 'You cannot send messages while silenced, restricted or banned.',
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/es-419/beatmapsets.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

'dialog' => [
'confirmation' => '¿Estás seguro de que quieres nominar este mapa?',
'different_nominator_warning' => '',
'different_nominator_warning' => 'Calificar este mapa con diferentes nominadores restablecerá su posición en la cola de calificación.',
'header' => 'Nominar mapa',
'hybrid_warning' => 'nota: solo puedes nominar una vez, así que asegúrate de que estás nominando todos los modos de juego que quieres nominar',
'current_main_ruleset' => 'El modo de juego principal es: :ruleset',
Expand Down
Loading

0 comments on commit 192db7b

Please sign in to comment.