Use correct endpoint to lookup by username

This commit is contained in:
Fedor Indutny 2022-10-19 13:41:47 -07:00 committed by GitHub
parent 85f706d48f
commit f5e94f2069
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View file

@ -691,6 +691,10 @@ export type ProfileType = Readonly<{
badges?: unknown;
}>;
export type AccountType = Readonly<{
uuid?: string;
}>;
export type GetIceServersResultType = Readonly<{
username: string;
password: string;
@ -861,7 +865,7 @@ export type WebAPIType = {
identifier: string,
options: GetProfileOptionsType
) => Promise<ProfileType>;
getProfileForUsername: (username: string) => Promise<ProfileType>;
getAccountForUsername: (username: string) => Promise<AccountType>;
getProfileUnauth: (
identifier: string,
options: GetProfileUnauthOptionsType
@ -1278,7 +1282,7 @@ export function initialize({
getKeysForIdentifierUnauth,
getMyKeys,
getProfile,
getProfileForUsername,
getAccountForUsername,
getProfileUnauth,
getBadgeImageFile,
getBoostBadgesFromServer,
@ -1661,13 +1665,15 @@ export function initialize({
})) as ProfileType;
}
async function getProfileForUsername(usernameToFetch: string) {
async function getAccountForUsername(usernameToFetch: string) {
return (await _ajax({
call: 'profile',
call: 'username',
httpType: 'GET',
urlParameters: `/username/${encodeURIComponent(usernameToFetch)}`,
urlParameters: `/${encodeURIComponent(usernameToFetch)}`,
responseType: 'json',
redactUrl: _createRedactor(usernameToFetch),
unauthenticated: true,
accessKey: undefined,
})) as ProfileType;
}