1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

allow querying users by id

This commit is contained in:
Robin Appelman 2020-07-18 16:21:25 +02:00
commit f4f1454d59
2 changed files with 5 additions and 0 deletions

View file

@ -28,6 +28,8 @@ class UserController extends BaseController {
$steamId = Parser::convertSteamIdToCommunityId($steamId);
} catch (InvalidArgumentException $e) {
}
} else if ($user = $this->userProvider->getById((int)$steamId)) {
Flight::json($user);
}
Flight::json($this->userProvider->get($steamId));
}

View file

@ -71,6 +71,9 @@ class UserProvider extends BaseProvider {
}
public function getById(int $userId): ?User {
if ($userId > pow(2, 31)) {
return null;
}
// first search in the view which contains the most used name for the users
$query = $this->getQueryBuilder();