Skip to content

Commit

Permalink
Merge branch 'master' into feature/shopify-php
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya authored Sep 27, 2024
2 parents d5c1b6a + 57d2c7a commit 3ef4315
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 88 deletions.
13 changes: 0 additions & 13 deletions app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace App\Http\Controllers;

use App\Exceptions\ModelNotSavedException;
use App\Exceptions\UserProfilePageLookupException;
use App\Exceptions\ValidationException;
use App\Http\Middleware\RequestCost;
use App\Libraries\ClientCheck;
Expand All @@ -24,7 +23,6 @@
use App\Models\Solo\Score as SoloScore;
use App\Models\User;
use App\Models\UserAccountHistory;
use App\Models\UserNotFound;
use App\Transformers\CurrentUserTransformer;
use App\Transformers\ScoreTransformer;
use App\Transformers\UserCompactTransformer;
Expand Down Expand Up @@ -114,17 +112,6 @@ private static function storeClientDisabledError()
], 403);
}

public function card($id)
{
try {
$user = FindForProfilePage::find($id, null, false);
} catch (UserProfilePageLookupException $e) {
$user = UserNotFound::instance();
}

return json_item($user, 'UserCompact', UserCompactTransformer::CARD_INCLUDES);
}

public function create()
{
if (!$GLOBALS['cfg']['osu']['user']['registration_mode']['web']) {
Expand Down
2 changes: 1 addition & 1 deletion app/Libraries/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function createAnnouncement(User $sender, array $rawParams)
throw new InvariantException('missing channel parameter');
}

$users = User::whereIn('user_id', $params['target_ids'])->get();
$users = User::find($params['target_ids']);
if ($users->isEmpty()) {
throw new InvariantException('Nobody to broadcast to!');
}
Expand Down
41 changes: 0 additions & 41 deletions app/Models/UserNotFound.php

This file was deleted.

10 changes: 7 additions & 3 deletions app/Transformers/UserCompactTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class UserCompactTransformer extends TransformerAbstract
];

const CARD_INCLUDES_PRELOAD = [
'country',
'userGroups',
];

Expand Down Expand Up @@ -193,9 +192,14 @@ public function includeCommentsCount(User $user)

public function includeCountry(User $user)
{
return $user->country === null
$countryAcronym = $user->country_acronym;
$country = $countryAcronym === null
? null
: app('countries')->byCode($countryAcronym);

return $country === null
? $this->primitive(null)
: $this->item($user->country, new CountryTransformer());
: $this->item($country, new CountryTransformer());
}

public function includeCover(User $user)
Expand Down
4 changes: 1 addition & 3 deletions docker/development/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ _run_dusk() {
docker compose run --rm -e APP_ENV=dusk.local php "$@"
}

genkey=0
if [ ! -f .env ]; then
echo "Copying default env file"
cp .env.example .env
genkey=1
fi

if [ -n "${GITHUB_TOKEN:-}" ]; then
Expand All @@ -37,7 +35,7 @@ _run composer install

_run artisan dusk:chrome-driver

if [ "$genkey" = 1 ]; then
if ! grep -q '^APP_KEY=.' .env; then
echo "Generating app key"
_run artisan key:generate
fi
Expand Down
17 changes: 4 additions & 13 deletions resources/js/components/user-card-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

import Reportable from 'interfaces/reportable';
import UserJson from 'interfaces/user-json';
import { route } from 'laroute';
import * as _ from 'lodash';
import { userNotFoundJson } from 'models/user';
import core from 'osu-core-singleton';
import * as React from 'react';
import { unmountComponentAtNode } from 'react-dom';
import { renderToStaticMarkup } from 'react-dom/server';
import { activeKeyDidChange as contextActiveKeyDidChange, ContainerContext, KeyContext, State as ActiveKeyState } from 'stateful-activation-context';
import { TooltipContext } from 'tooltip-context';
import { presence } from 'utils/string';
import { apiLookupUsers } from 'utils/user';
import { UserCard } from './user-card';

interface Props {
Expand Down Expand Up @@ -224,21 +225,11 @@ export class UserCardTooltip extends React.PureComponent<Props, State> {
}

componentDidMount() {
this.getUser().then((user) => {
this.setState({ user });
apiLookupUsers([this.props.lookup]).done((response) => {
this.setState({ user: response.users[0] ?? userNotFoundJson });
});
}

getUser() {
const url = route('users.card', { user: this.props.lookup });

return $.ajax({
dataType: 'json',
type: 'GET',
url,
}) as JQuery.jqXHR<UserJson>;
}

render() {
const activated = this.state.activeKey === this.props.lookup;

Expand Down
13 changes: 7 additions & 6 deletions resources/js/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ export default class User {
}
}

const deletedUser = new User(-1);
export const deletedUser = new User(-1);
deletedUser.isDeleted = true;
deletedUser.username = trans('users.deleted');
Object.freeze(deletedUser);

const deletedUserJson = Object.freeze(deletedUser.toJson());
export const deletedUserJson = Object.freeze(deletedUser.toJson());

export {
deletedUser,
deletedUserJson,
};
const userNotFound = new User(-1);
userNotFound.username = trans('supporter_tag.user_search.not_found');
Object.freeze(userNotFound);

export const userNotFoundJson = Object.freeze(userNotFound.toJson());
7 changes: 1 addition & 6 deletions resources/js/store/store-supporter-tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UserJson from 'interfaces/user-json';
import { debounce } from 'lodash';
import { action, autorun, computed, makeObservable, observable, runInAction } from 'mobx';
import { disposeOnUnmount, observer } from 'mobx-react';
import User from 'models/user';
import { userNotFoundJson } from 'models/user';
import core from 'osu-core-singleton';
import React from 'react';
import { onError } from 'utils/ajax';
Expand All @@ -22,11 +22,6 @@ const jsonId = 'json-store-supporter-tag';
const maxValue = 52;
const minValue = 4;

const userNotFound = new User(-1);
userNotFound.username = trans('supporter_tag.user_search.not_found');

const userNotFoundJson = Object.freeze(userNotFound.toJson());

interface Props {
maxMessageLength: number;
}
Expand Down
2 changes: 0 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@
Route::post('users/store-web', 'UsersController@storeWeb')->name('users.store-web');

Route::group(['as' => 'users.', 'prefix' => 'users/{user}'], function () {
Route::get('card', 'UsersController@card')->name('card');
Route::get('extra-pages/{page}', 'UsersController@extraPages')->name('extra-page');
Route::put('page', 'UsersController@updatePage')->name('page');
Route::group(['namespace' => 'Users'], function () {
Expand Down Expand Up @@ -361,7 +360,6 @@
Route::get('approved', 'PaypalController@approved')->name('approved');
Route::get('declined', 'PaypalController@declined')->name('declined');
Route::post('create', 'PaypalController@create')->name('create');
Route::get('completed', 'PaypalController@completed')->name('completed');
Route::post('ipn', 'PaypalController@ipn')->name('ipn');
});

Expand Down

0 comments on commit 3ef4315

Please sign in to comment.