Skip to content

Commit 4d6cea9

Browse files
committed
Update ApiV1Dot1Controller, fix username to id endpoint
1 parent 679ef67 commit 4d6cea9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Http/Controllers/Api/ApiV1Dot1Controller.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ public function accountUsernameToId(Request $request, $username)
950950
{
951951
abort_if(! $request->user() || ! $request->user()->token() || ! $username, 403);
952952
abort_unless($request->user()->tokenCan('read'), 403);
953-
953+
$username = trim($username);
954954
$rateLimiting = (bool) config_cache('api.rate-limits.v1Dot1.accounts.usernameToId.enabled');
955955
$ipRateLimiting = (bool) config_cache('api.rate-limits.v1Dot1.accounts.usernameToId.ip_enabled');
956956
if ($ipRateLimiting) {
@@ -997,6 +997,11 @@ public function accountUsernameToId(Request $request, $username)
997997
'X-Rate-Limit-Reset' => RateLimiter::availableIn($userKey),
998998
];
999999
}
1000+
if(str_ends_with($username, config_cache('pixelfed.domain.app'))) {
1001+
$pre = str_starts_with($username, '@') ? substr($username, 1) : $username;
1002+
$parts = explode('@', $pre);
1003+
$username = $parts[0];
1004+
}
10001005
$accountId = AccountService::usernameToId($username, true);
10011006
if (! $accountId) {
10021007
return [];

0 commit comments

Comments
 (0)