mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-29 09:43:16 +00:00
Update ApiV1Dot1Controller, fix username to id endpoint
This commit is contained in:
parent
679ef677b7
commit
4d6cea9aa4
1 changed files with 6 additions and 1 deletions
|
@ -950,7 +950,7 @@ class ApiV1Dot1Controller extends Controller
|
|||
{
|
||||
abort_if(! $request->user() || ! $request->user()->token() || ! $username, 403);
|
||||
abort_unless($request->user()->tokenCan('read'), 403);
|
||||
|
||||
$username = trim($username);
|
||||
$rateLimiting = (bool) config_cache('api.rate-limits.v1Dot1.accounts.usernameToId.enabled');
|
||||
$ipRateLimiting = (bool) config_cache('api.rate-limits.v1Dot1.accounts.usernameToId.ip_enabled');
|
||||
if ($ipRateLimiting) {
|
||||
|
@ -997,6 +997,11 @@ class ApiV1Dot1Controller extends Controller
|
|||
'X-Rate-Limit-Reset' => RateLimiter::availableIn($userKey),
|
||||
];
|
||||
}
|
||||
if(str_ends_with($username, config_cache('pixelfed.domain.app'))) {
|
||||
$pre = str_starts_with($username, '@') ? substr($username, 1) : $username;
|
||||
$parts = explode('@', $pre);
|
||||
$username = $parts[0];
|
||||
}
|
||||
$accountId = AccountService::usernameToId($username, true);
|
||||
if (! $accountId) {
|
||||
return [];
|
||||
|
|
Loading…
Reference in a new issue