Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into oauth-verification-2
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Jan 26, 2024
2 parents 095daa0 + e7cc303 commit 9a04ce8
Show file tree
Hide file tree
Showing 281 changed files with 3,894 additions and 3,218 deletions.
4 changes: 2 additions & 2 deletions .env.dusk.local.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
APP_KEY=
APP_ENV=testing

APP_URL=http://localhost:8000
NOTIFICATION_ENDPOINT=ws://notification-server-dusk:2345
APP_URL=http://nginx:8008
NOTIFICATION_ENDPOINT=ws://nginx:8008/home/notifications/feed

DB_DATABASE=osu_test
DB_DATABASE_CHAT=osu_chat_test
Expand Down
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ CLIENT_CHECK_VERSION=false
# SCORES_ES_CACHE_DURATION=
# SCORES_EXPERIMENTAL_RANK_AS_DEFAULT=false
# SCORES_EXPERIMENTAL_RANK_AS_EXTRA=false
# SCORES_PROCESSING_QUEUE=osu-queue:score-statistics
# SCORES_RANK_CACHE_LOCAL_SERVER=0
# SCORES_RANK_CACHE_MIN_USERS=35000
# SCORES_RANK_CACHE_SERVER_URL=
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Install js dependencies
run: yarn --frozen-lockfile

- run: 'yarn lint --max-warnings 94 > /dev/null'
- run: 'yarn lint --max-warnings 89 > /dev/null'

- run: ./bin/update_licence.sh -nf

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ _ide_helper.php
/vendor
composer.phar

# docker related local files
/compose.override.yml

# OS-specific crud
.DS_Store
Thumbs.db
Expand Down
8 changes: 1 addition & 7 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ Start docker in background:

```
bin/docker_dev.sh -d
# alternatively
# docker compose up -d
```

Start single docker service:
Expand Down Expand Up @@ -188,13 +186,9 @@ docker compose run --rm php mysql
Docker images need to be occasionally updated to make sure they're running latest version of the packages.

```
docker compose down --rmi all
docker compose pull
docker compose build --pull
docker compose build --no-cache
```

(don't use `build --no-cache` as it'll end up rebuilding `php` image multiple times)

#### Faster php commands

When frequently running commands, doing `docker compose run` may feel a little bit slow. An alternative is by running the command in existing instance instead. For example to run `artisan tinker`:
Expand Down
41 changes: 41 additions & 0 deletions app/Casts/LegacyFilename.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

declare(strict_types=1);

namespace App\Casts;

use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;

class LegacyFilename implements CastsAttributes
{
public static function makeFromAttributes(?array $attributes): ?string
{
if (!isset($attributes['hash'])) {
return null;
}

$filename = $attributes['hash'];
if (isset($attributes['ext'])) {
$filename .= ".{$attributes['ext']}";
}

return $filename;
}

public function get(Model $model, string $key, mixed $value, array $attributes)
{
return static::makeFromAttributes($attributes);
}

public function set(Model $model, string $key, mixed $value, array $attributes)
{
return [
'ext' => null,
'hash' => $value,
];
}
}
2 changes: 1 addition & 1 deletion app/Console/Commands/ForumTopicCoversCleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function handle()

$deleted++;
$progress->advance();
$cover->deleteWithFile();
$cover->delete();
}
});

Expand Down
19 changes: 19 additions & 0 deletions app/Enums/ScoreRank.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Enums;

enum ScoreRank: string
{
case A = 'A';
case B = 'B';
case C = 'C';
case D = 'D';
case F = 'F';
case S = 'S';
case SH = 'SH';
case X = 'X';
case XH = 'XH';
}
7 changes: 4 additions & 3 deletions app/Http/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function cover()
}

try {
$user
->profileCustomization()
->setCover(Request::input('cover_id'), Request::file('cover_file'));
$profile = $user->profileCustomization();
$profile->cover()->set(Request::input('cover_id'), Request::file('cover_file'));
$profile->save();
} catch (ImageProcessorException $e) {
return error_popup($e->getMessage());
}
Expand Down Expand Up @@ -257,6 +257,7 @@ public function updateOptions()
'comments_sort:string',
'extras_order:string[]',
'forum_posts_show_deleted:bool',
'legacy_score_only:bool',
'profile_cover_expanded:bool',
'user_list_filter:string',
'user_list_sort:string',
Expand Down
6 changes: 1 addition & 5 deletions app/Http/Controllers/Admin/ContestsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\Models\Contest;
use App\Models\DeletedUser;
use App\Models\UserContestEntry;
use GuzzleHttp;
use ZipStream\ZipStream;

class ContestsController extends Controller
Expand Down Expand Up @@ -47,14 +46,11 @@ public function gimmeZip($id)
return response()->streamDownload(function () use ($entries) {
$zip = new ZipStream();

$client = new GuzzleHttp\Client();

$deletedUser = new DeletedUser();
foreach ($entries as $entry) {
$targetDir = ($entry->user ?? $deletedUser)->username." ({$entry->user_id})";
$filename = sanitize_filename($entry->original_filename);
$file = $client->get($entry->fileUrl())->getBody();
$zip->addFileFromPsr7Stream("$targetDir/{$filename}", $file);
$zip->addFile("$targetDir/{$filename}", $entry->file()->get());
}

$zip->finish();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ContestEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function destroy($id)

priv_check('ContestEntryDestroy', $entry)->ensureCan();

$entry->deleteWithFile();
$entry->delete();

return $contest->userEntries($user);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Forum/TopicCoversController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function destroy($id)
if ($cover !== null) {
priv_check('ForumTopicCoverEdit', $cover)->ensureCan();

$cover->deleteWithFile();
$cover->delete();
}

return json_item($cover, new TopicCoverTransformer());
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/PasswordResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Libraries\User\PasswordResetData;
use App\Models\User;
use App\Models\UserAccountHistory;
use Carbon\CarbonImmutable;

class PasswordResetController extends Controller
{
Expand Down Expand Up @@ -124,6 +125,7 @@ public function update()
}

$user->validatePasswordConfirmation();
$params['user']['user_lastvisit'] = CarbonImmutable::now();
if ($user->update($params['user'])) {
$user->resetSessions();
$this->login($user);
Expand Down
5 changes: 5 additions & 0 deletions app/Http/Controllers/SessionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public function store()
if ($forceReactivation->isRequired()) {
$forceReactivation->run();

\Session::flash('password_reset_start', [
'reason' => $forceReactivation->getReason(),
'username' => $username,
]);

return ujs_redirect(route('password-reset'));
}

Expand Down
7 changes: 4 additions & 3 deletions app/Http/Middleware/UpdateUserLastvisit.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public function handle($request, Closure $next)
private function recordSession($request)
{
// Add metadata to session to help user recognize this login location
$countryCode = presence(request_country($request)) ?? Country::UNKNOWN;
$countryCode = request_country($request);
$country = $countryCode === null ? null : app('countries')->byCode($countryCode);
$request->session()->put('meta', [
'agent' => $request->header('User-Agent'),
'country' => [
'code' => $countryCode,
'name' => presence(Country::where('acronym', $countryCode)->pluck('name')->first()) ?? 'Unknown',
'code' => $country?->acronym ?? Country::UNKNOWN,
'name' => presence($country?->name) ?? 'Unknown',
],
'ip' => $request->ip(),
'last_visit' => Carbon::now(),
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/Notifications/ForumTopicReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getDetails(): array
return [
'title' => $this->post->topic->topic_title,
'post_id' => $this->post->getKey(),
'cover_url' => optional($this->post->topic->cover)->fileUrl(),
'cover_url' => $this->post->topic->cover?->file()->url(),
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Libraries/BBCodeFromDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function parseBoxHelperPrefix($linkText = null)
{
$linkText = presence($linkText) ?? 'SPOILER';

return "<div class='js-spoilerbox bbcode-spoilerbox'><button class='js-spoilerbox__link bbcode-spoilerbox__link' type='button'><span class='bbcode-spoilerbox__link-icon'></span>{$linkText}</button><div class='bbcode-spoilerbox__body'>";
return "<div class='js-spoilerbox bbcode-spoilerbox'><a class='js-spoilerbox__link bbcode-spoilerbox__link' href='#'><span class='bbcode-spoilerbox__link-icon'></span>{$linkText}</a><div class='bbcode-spoilerbox__body'>";
}

public function parseBoxHelperSuffix()
Expand Down
8 changes: 0 additions & 8 deletions app/Libraries/CleanHTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ public function __construct()
]
);

$def->addElement(
'button',
'Formctrl',
'Optional: #PCDATA | Heading | List | Block | Inline',
'Common',
['type' => 'Enum#button'],
);

$def->addAttribute('audio', 'preload', 'Text');

$def->addAttribute('img', 'loading', 'Text');
Expand Down
35 changes: 0 additions & 35 deletions app/Libraries/ForumDefaultTopicCover.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Libraries/Opengraph/Forum/ForumOpengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function get(): array
return [
'description' => $this->description(),
'title' => $this->forum->forum_name,
'image' => $this->forum->cover?->fileUrl(),
'image' => $this->forum->cover?->file()->url(),
];
}
}
2 changes: 1 addition & 1 deletion app/Libraries/Opengraph/Forum/TopicOpengraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function get(): array

return [
'description' => "{$forumDescription} » {$this->topic->topic_title}",
'image' => $this->topic->cover?->fileUrl() ?? $this->topic->forum->cover?->defaultTopicCover->fileUrl(),
'image' => $this->topic->cover?->file()->url() ?? $this->topic->forum->cover?->defaultTopicCover->url(),
'title' => $this->topic->topic_title,
];
}
Expand Down
Loading

0 comments on commit 9a04ce8

Please sign in to comment.