Skip to content

Commit

Permalink
Simplify naming of endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Feb 7, 2025
1 parent 5e74d82 commit 41c8f64
Show file tree
Hide file tree
Showing 35 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion osu.Desktop/DiscordRichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private void updatePresence(bool hideIdentifiableInformation)
new Button
{
Label = "View beatmap",
Url = $@"{api.EndpointConfiguration.WebsiteRootUrl}/beatmaps/{beatmapId}?mode={ruleset.Value.ShortName}"
Url = $@"{api.Endpoints.WebsiteUrl}/beatmaps/{beatmapId}?mode={ruleset.Value.ShortName}"
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Menus/TestSceneMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void TestOnlineMenuBannerTrusted()
new APIMenuImage
{
Image = @"https://assets.ppy.sh/main-menu/[email protected]",
Url = $@"{API.EndpointConfiguration.WebsiteRootUrl}/home/news/2023-12-21-project-loved-december-2023",
Url = $@"{API.Endpoints.WebsiteUrl}/home/news/2023-12-21-project-loved-december-2023",
}
}
});
Expand Down
10 changes: 5 additions & 5 deletions osu.Game.Tests/Visual/Online/TestSceneWikiMarkdownContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ public void Setup() => Schedule(() =>
[Test]
public void TestLink()
{
AddStep("set current path", () => markdownContainer.CurrentPath = $"{API.EndpointConfiguration.WebsiteRootUrl}/wiki/Article_styling_criteria/");
AddStep("set current path", () => markdownContainer.CurrentPath = $"{API.Endpoints.WebsiteUrl}/wiki/Article_styling_criteria/");

AddStep("set '/wiki/Main_page''", () => markdownContainer.Text = "[wiki main page](/wiki/Main_page)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.EndpointConfiguration.WebsiteRootUrl}/wiki/Main_page");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.Endpoints.WebsiteUrl}/wiki/Main_page");

AddStep("set '../FAQ''", () => markdownContainer.Text = "[FAQ](../FAQ)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.EndpointConfiguration.WebsiteRootUrl}/wiki/FAQ");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.Endpoints.WebsiteUrl}/wiki/FAQ");

AddStep("set './Writing''", () => markdownContainer.Text = "[wiki writing guidline](./Writing)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.EndpointConfiguration.WebsiteRootUrl}/wiki/Article_styling_criteria/Writing");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.Endpoints.WebsiteUrl}/wiki/Article_styling_criteria/Writing");

AddStep("set 'Formatting''", () => markdownContainer.Text = "[wiki formatting guidline](Formatting)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.EndpointConfiguration.WebsiteRootUrl}/wiki/Article_styling_criteria/Formatting");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.Endpoints.WebsiteUrl}/wiki/Article_styling_criteria/Formatting");
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Beatmaps/BeatmapInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static bool Match(this IBeatmapInfo beatmapInfo, params FilterCriteria.Op
if (beatmapInfo.OnlineID <= 0 || beatmapInfo.BeatmapSet == null)
return null;

return $@"{api.EndpointConfiguration.WebsiteRootUrl}/beatmapsets/{beatmapInfo.BeatmapSet.OnlineID}#{ruleset?.ShortName ?? beatmapInfo.Ruleset.ShortName}/{beatmapInfo.OnlineID}";
return $@"{api.Endpoints.WebsiteUrl}/beatmapsets/{beatmapInfo.BeatmapSet.OnlineID}#{ruleset?.ShortName ?? beatmapInfo.Ruleset.ShortName}/{beatmapInfo.OnlineID}";
}
}
}
4 changes: 2 additions & 2 deletions osu.Game/Beatmaps/BeatmapSetInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public static class BeatmapSetInfoExtensions
return null;

if (ruleset != null)
return $@"{api.EndpointConfiguration.WebsiteRootUrl}/beatmapsets/{beatmapSetInfo.OnlineID}#{ruleset.ShortName}";
return $@"{api.Endpoints.WebsiteUrl}/beatmapsets/{beatmapSetInfo.OnlineID}#{ruleset.ShortName}";

return $@"{api.EndpointConfiguration.WebsiteRootUrl}/beatmapsets/{beatmapSetInfo.OnlineID}";
return $@"{api.Endpoints.WebsiteUrl}/beatmapsets/{beatmapSetInfo.OnlineID}";
}
}
}
12 changes: 6 additions & 6 deletions osu.Game/Online/API/APIAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public partial class APIAccess : Component, IAPIProvider

private readonly Queue<APIRequest> queue = new Queue<APIRequest>();

public EndpointConfiguration EndpointConfiguration { get; }
public EndpointConfiguration Endpoints { get; }

/// <summary>
/// The API response version.
Expand Down Expand Up @@ -73,7 +73,7 @@ public partial class APIAccess : Component, IAPIProvider
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
private readonly Logger log;

public APIAccess(OsuGameBase game, OsuConfigManager config, EndpointConfiguration endpointConfiguration, string versionHash)
public APIAccess(OsuGameBase game, OsuConfigManager config, EndpointConfiguration endpoints, string versionHash)
{
this.game = game;
this.config = config;
Expand All @@ -87,13 +87,13 @@ public APIAccess(OsuGameBase game, OsuConfigManager config, EndpointConfiguratio
APIVersion = now.Year * 10000 + now.Month * 100 + now.Day;
}

EndpointConfiguration = endpointConfiguration;
Endpoints = endpoints;
NotificationsClient = setUpNotificationsClient();

authentication = new OAuth(endpointConfiguration.APIClientID, endpointConfiguration.APIClientSecret, EndpointConfiguration.APIEndpointUrl);
authentication = new OAuth(endpoints.APIClientID, endpoints.APIClientSecret, Endpoints.APIUrl);

log = Logger.GetLogger(LoggingTarget.Network);
log.Add($@"API endpoint root: {EndpointConfiguration.APIEndpointUrl}");
log.Add($@"API endpoint root: {Endpoints.APIUrl}");
log.Add($@"API request version: {APIVersion}");

ProvidedUsername = config.Get<string>(OsuSetting.Username);
Expand Down Expand Up @@ -405,7 +405,7 @@ public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email,

var req = new RegistrationRequest
{
Url = $@"{EndpointConfiguration.APIEndpointUrl}/users",
Url = $@"{Endpoints.APIUrl}/users",
Method = HttpMethod.Post,
Username = username,
Email = email,
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/API/APIRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public abstract class APIRequest

protected virtual WebRequest CreateWebRequest() => new OsuWebRequest(Uri);

protected virtual string Uri => $@"{API!.EndpointConfiguration.APIEndpointUrl}/api/v2/{Target}";
protected virtual string Uri => $@"{API!.Endpoints.APIUrl}/api/v2/{Target}";

protected IAPIProvider? API;

Expand Down
6 changes: 3 additions & 3 deletions osu.Game/Online/API/DummyAPIAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public partial class DummyAPIAccess : Component, IAPIProvider

public string ProvidedUsername => LocalUser.Value.Username;

public EndpointConfiguration EndpointConfiguration { get; } = new EndpointConfiguration
public EndpointConfiguration Endpoints { get; } = new EndpointConfiguration
{
APIEndpointUrl = "http://localhost",
WebsiteRootUrl = "http://localhost",
APIUrl = "http://localhost",
WebsiteUrl = "http://localhost",
};

public int APIVersion => int.Parse(DateTime.Now.ToString("yyyyMMdd"));
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/API/IAPIProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public interface IAPIProvider
/// <summary>
/// Holds configuration for online endpoints.
/// </summary>
EndpointConfiguration EndpointConfiguration { get; }
EndpointConfiguration Endpoints { get; }

/// <summary>
/// The version of the API.
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Online/API/Requests/PatchBeatmapPackageRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ protected override string Uri
get
{
// can be removed once the service has been successfully deployed to production
if (API!.EndpointConfiguration.BeatmapSubmissionServiceUrl == null)
if (API!.Endpoints.BeatmapSubmissionServiceUrl == null)
throw new NotSupportedException("Beatmap submission not supported in this configuration!");

return $@"{API!.EndpointConfiguration.BeatmapSubmissionServiceUrl!}/beatmapsets/{BeatmapSetID}";
return $@"{API!.Endpoints.BeatmapSubmissionServiceUrl!}/beatmapsets/{BeatmapSetID}";
}
}

Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Online/API/Requests/PutBeatmapSetRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ protected override string Uri
get
{
// can be removed once the service has been successfully deployed to production
if (API!.EndpointConfiguration.BeatmapSubmissionServiceUrl == null)
if (API!.Endpoints.BeatmapSubmissionServiceUrl == null)
throw new NotSupportedException("Beatmap submission not supported in this configuration!");

return $@"{API!.EndpointConfiguration.BeatmapSubmissionServiceUrl}/beatmapsets";
return $@"{API!.Endpoints.BeatmapSubmissionServiceUrl}/beatmapsets";
}
}

Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Online/API/Requests/ReplaceBeatmapPackageRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ protected override string Uri
get
{
// can be removed once the service has been successfully deployed to production
if (API!.EndpointConfiguration.BeatmapSubmissionServiceUrl == null)
if (API!.Endpoints.BeatmapSubmissionServiceUrl == null)
throw new NotSupportedException("Beatmap submission not supported in this configuration!");

return $@"{API!.EndpointConfiguration.BeatmapSubmissionServiceUrl}/beatmapsets/{BeatmapSetID}";
return $@"{API!.Endpoints.BeatmapSubmissionServiceUrl}/beatmapsets/{BeatmapSetID}";
}
}

Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Online/Chat/ExternalLinkOpener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public void OpenUrlExternally(string url, LinkWarnMode warnMode = LinkWarnMode.D

if (url.StartsWith('/'))
{
url = $"{api.EndpointConfiguration.WebsiteRootUrl}{url}";
url = $"{api.Endpoints.WebsiteUrl}{url}";
isTrustedDomain = true;
}
else
{
isTrustedDomain = url.StartsWith(api.EndpointConfiguration.WebsiteRootUrl, StringComparison.Ordinal);
isTrustedDomain = url.StartsWith(api.Endpoints.WebsiteUrl, StringComparison.Ordinal);
}

if (!url.CheckIsValidUrl())
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/Chat/NowPlayingCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected override void LoadComplete()

string getBeatmapPart()
{
return beatmapOnlineID > 0 ? $"[{api.EndpointConfiguration.WebsiteRootUrl}/b/{beatmapOnlineID} {beatmapDisplayTitle}]" : beatmapDisplayTitle;
return beatmapOnlineID > 0 ? $"[{api.Endpoints.WebsiteUrl}/b/{beatmapOnlineID} {beatmapDisplayTitle}]" : beatmapDisplayTitle;
}

string getRulesetPart()
Expand Down
8 changes: 4 additions & 4 deletions osu.Game/Online/DevelopmentEndpointConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public class DevelopmentEndpointConfiguration : EndpointConfiguration
{
public DevelopmentEndpointConfiguration()
{
WebsiteRootUrl = APIEndpointUrl = @"https://dev.ppy.sh";
WebsiteUrl = APIUrl = @"https://dev.ppy.sh";
APIClientSecret = @"3LP2mhUrV89xxzD1YKNndXHEhWWCRLPNKioZ9ymT";
APIClientID = "5";
SpectatorEndpointUrl = $@"{APIEndpointUrl}/signalr/spectator";
MultiplayerEndpointUrl = $@"{APIEndpointUrl}/signalr/multiplayer";
MetadataEndpointUrl = $@"{APIEndpointUrl}/signalr/metadata";
SpectatorUrl = $@"{APIUrl}/signalr/spectator";
MultiplayerUrl = $@"{APIUrl}/signalr/multiplayer";
MetadataUrl = $@"{APIUrl}/signalr/metadata";
}
}
}
32 changes: 16 additions & 16 deletions osu.Game/Online/EndpointConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@ namespace osu.Game.Online
public class EndpointConfiguration
{
/// <summary>
/// The base URL for the website. Does not include a trailing slash.
/// The OAuth client secret.
/// </summary>
public string WebsiteRootUrl { get; set; } = string.Empty;
public string APIClientSecret { get; set; } = string.Empty;

/// <summary>
/// The endpoint for the main (osu-web) API. Does not include a trailing slash.
/// The OAuth client ID.
/// </summary>
public string APIEndpointUrl { get; set; } = string.Empty;
public string APIClientID { get; set; } = string.Empty;

/// <summary>
/// The OAuth client secret.
/// The base URL for the website. Does not include a trailing slash.
/// </summary>
public string APIClientSecret { get; set; } = string.Empty;
public string WebsiteUrl { get; set; } = string.Empty;

/// <summary>
/// The OAuth client ID.
/// The endpoint for the main (osu-web) API. Does not include a trailing slash.
/// </summary>
public string APIClientID { get; set; } = string.Empty;
public string APIUrl { get; set; } = string.Empty;

/// <summary>
/// The endpoint for the SignalR spectator server.
/// The root URL for the service handling beatmap submission. Does not include a trailing slash.
/// </summary>
public string SpectatorEndpointUrl { get; set; } = string.Empty;
public string? BeatmapSubmissionServiceUrl { get; set; }

/// <summary>
/// The endpoint for the SignalR multiplayer server.
/// The endpoint for the SignalR spectator server.
/// </summary>
public string MultiplayerEndpointUrl { get; set; } = string.Empty;
public string SpectatorUrl { get; set; } = string.Empty;

/// <summary>
/// The endpoint for the SignalR metadata server.
/// The endpoint for the SignalR multiplayer server.
/// </summary>
public string MetadataEndpointUrl { get; set; } = string.Empty;
public string MultiplayerUrl { get; set; } = string.Empty;

/// <summary>
/// The root URL for the service handling beatmap submission. Does not include a trailing slash.
/// The endpoint for the SignalR metadata server.
/// </summary>
public string? BeatmapSubmissionServiceUrl { get; set; }
public string MetadataUrl { get; set; } = string.Empty;
}
}
2 changes: 1 addition & 1 deletion osu.Game/Online/Leaderboards/LeaderboardScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public MenuItem[] ContextMenuItems
items.Add(new OsuMenuItem("Use these mods", MenuItemType.Highlighted, () => songSelect.Mods.Value = Score.Mods));

if (Score.OnlineID > 0)
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => clipboard?.SetText($@"{api.EndpointConfiguration.WebsiteRootUrl}/scores/{Score.OnlineID}")));
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => clipboard?.SetText($@"{api.Endpoints.WebsiteUrl}/scores/{Score.OnlineID}")));

if (Score.Files.Count > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/Metadata/OnlineMetadataClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public partial class OnlineMetadataClient : MetadataClient

public OnlineMetadataClient(EndpointConfiguration endpoints)
{
endpoint = endpoints.MetadataEndpointUrl;
endpoint = endpoints.MetadataUrl;
}

[BackgroundDependencyLoader]
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class OnlineMultiplayerClient : MultiplayerClient

public OnlineMultiplayerClient(EndpointConfiguration endpoints)
{
endpoint = endpoints.MultiplayerEndpointUrl;
endpoint = endpoints.MultiplayerUrl;
}

[BackgroundDependencyLoader]
Expand Down
8 changes: 4 additions & 4 deletions osu.Game/Online/ProductionEndpointConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public class ProductionEndpointConfiguration : EndpointConfiguration
{
public ProductionEndpointConfiguration()
{
WebsiteRootUrl = APIEndpointUrl = @"https://osu.ppy.sh";
WebsiteUrl = APIUrl = @"https://osu.ppy.sh";
APIClientSecret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
APIClientID = "5";
SpectatorEndpointUrl = "https://spectator.ppy.sh/spectator";
MultiplayerEndpointUrl = "https://spectator.ppy.sh/multiplayer";
MetadataEndpointUrl = "https://spectator.ppy.sh/metadata";
SpectatorUrl = "https://spectator.ppy.sh/spectator";
MultiplayerUrl = "https://spectator.ppy.sh/multiplayer";
MetadataUrl = "https://spectator.ppy.sh/metadata";
}
}
}
2 changes: 1 addition & 1 deletion osu.Game/Online/Spectator/OnlineSpectatorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class OnlineSpectatorClient : SpectatorClient

public OnlineSpectatorClient(EndpointConfiguration endpoints)
{
endpoint = endpoints.SpectatorEndpointUrl;
endpoint = endpoints.SpectatorUrl;
}

[BackgroundDependencyLoader]
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/OsuGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private void load(ReadableKeyCombinationProvider keyCombinationProvider, Framewo

EndpointConfiguration endpoints = CreateEndpoints();

MessageFormatter.WebsiteRootUrl = endpoints.WebsiteRootUrl;
MessageFormatter.WebsiteRootUrl = endpoints.WebsiteUrl;

frameworkLocale = frameworkConfig.GetBindable<string>(FrameworkSetting.Locale);
frameworkLocale.BindValueChanged(_ => updateLanguage());
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Comments/DrawableComment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private void deleteCommentRequest()

private void copyUrl()
{
clipboard.SetText($@"{api.EndpointConfiguration.APIEndpointUrl}/comments/{Comment.Id}");
clipboard.SetText($@"{api.Endpoints.APIUrl}/comments/{Comment.Id}");
onScreenDisplay?.Display(new CopyUrlToast());
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Login/LoginForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void load(OsuConfigManager config, AccountCreationOverlay accountCreatio
}
};

forgottenPasswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.EndpointConfiguration.WebsiteRootUrl}/home/password-reset");
forgottenPasswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.Endpoints.WebsiteUrl}/home/password-reset");

password.OnCommit += (_, _) => performLogin();

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Login/SecondFactorAuthForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void load()
explainText.AddParagraph(UserVerificationStrings.BoxInfoCheckSpam);
// We can't support localisable strings with nested links yet. Not sure if we even can (probably need to allow markdown link formatting or something).
explainText.AddParagraph("If you can't access your email or have forgotten what you used, please follow the ");
explainText.AddLink(UserVerificationStrings.BoxInfoRecoverLink, $"{api.EndpointConfiguration.WebsiteRootUrl}/home/password-reset");
explainText.AddLink(UserVerificationStrings.BoxInfoRecoverLink, $"{api.Endpoints.WebsiteUrl}/home/password-reset");
explainText.AddText(". You can also ");
explainText.AddLink(UserVerificationStrings.BoxInfoReissueLink, () =>
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ private void updateDisplay(APIUser? user)
}

topLinkContainer.AddText("Contributed ");
topLinkContainer.AddLink("forum post".ToQuantity(user.PostCount, "#,##0"), $"{api.EndpointConfiguration.WebsiteRootUrl}/users/{user.Id}/posts", creationParameters: embolden);
topLinkContainer.AddLink("forum post".ToQuantity(user.PostCount, "#,##0"), $"{api.Endpoints.WebsiteUrl}/users/{user.Id}/posts", creationParameters: embolden);

addSpacer(topLinkContainer);

topLinkContainer.AddText("Posted ");
topLinkContainer.AddLink("comment".ToQuantity(user.CommentsCount, "#,##0"), $"{api.EndpointConfiguration.WebsiteRootUrl}/comments?user_id={user.Id}", creationParameters: embolden);
topLinkContainer.AddLink("comment".ToQuantity(user.CommentsCount, "#,##0"), $"{api.Endpoints.WebsiteUrl}/comments?user_id={user.Id}", creationParameters: embolden);

string websiteWithoutProtocol = user.Website;

Expand Down
Loading

0 comments on commit 41c8f64

Please sign in to comment.