mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Use correct lookup type to ensure username based lookups always prefer username
This commit is contained in:
parent
7c60c6a733
commit
1c4a3c584a
@ -8,8 +8,9 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
public class GetUserRequest : APIRequest<User>
|
public class GetUserRequest : APIRequest<User>
|
||||||
{
|
{
|
||||||
private readonly string userIdentifier;
|
private readonly string lookup;
|
||||||
public readonly RulesetInfo Ruleset;
|
public readonly RulesetInfo Ruleset;
|
||||||
|
private readonly LookupType lookupType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the currently logged-in user.
|
/// Gets the currently logged-in user.
|
||||||
@ -25,7 +26,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
/// <param name="ruleset">The ruleset to get the user's info for.</param>
|
/// <param name="ruleset">The ruleset to get the user's info for.</param>
|
||||||
public GetUserRequest(long? userId = null, RulesetInfo ruleset = null)
|
public GetUserRequest(long? userId = null, RulesetInfo ruleset = null)
|
||||||
{
|
{
|
||||||
this.userIdentifier = userId.ToString();
|
lookup = userId.ToString();
|
||||||
|
lookupType = LookupType.Id;
|
||||||
Ruleset = ruleset;
|
Ruleset = ruleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,10 +38,17 @@ namespace osu.Game.Online.API.Requests
|
|||||||
/// <param name="ruleset">The ruleset to get the user's info for.</param>
|
/// <param name="ruleset">The ruleset to get the user's info for.</param>
|
||||||
public GetUserRequest(string username = null, RulesetInfo ruleset = null)
|
public GetUserRequest(string username = null, RulesetInfo ruleset = null)
|
||||||
{
|
{
|
||||||
this.userIdentifier = username;
|
lookup = username;
|
||||||
|
lookupType = LookupType.Username;
|
||||||
Ruleset = ruleset;
|
Ruleset = ruleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => userIdentifier != null ? $@"users/{userIdentifier}/{Ruleset?.ShortName}" : $@"me/{Ruleset?.ShortName}";
|
protected override string Target => lookup != null ? $@"users/{lookup}/{Ruleset?.ShortName}?k={lookupType.ToString().ToLower()}" : $@"me/{Ruleset?.ShortName}";
|
||||||
|
|
||||||
|
private enum LookupType
|
||||||
|
{
|
||||||
|
Id,
|
||||||
|
Username
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user