Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions GenOnlineService/ExternalLeaderboardsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ public class EloRefreshEntry

public static class ExternalLeaderboardsClient
{
private static void GetExternalLeaderboardsConfig(out string baseUrl, out string postToken, out string getToken)
private static void GetExternalLeaderboardsConfig(out string postUrl, out string getUrl, out string postToken, out string getToken)
{
baseUrl = string.Empty;
postUrl = string.Empty;
getUrl = string.Empty;
postToken = string.Empty;
getToken = string.Empty;

Expand All @@ -46,13 +47,19 @@ private static void GetExternalLeaderboardsConfig(out string baseUrl, out string
throw new Exception("ExternalLeaderboards section missing in config");
}

string? sectionBaseUrl = configSection.GetValue<string>("BaseUrl");
string? sectionPostUrl = configSection.GetValue<string>("PostUrl");
string? sectionGetUrl = configSection.GetValue<string>("GetUrl");
string? sectionPostToken = configSection.GetValue<string>("PostToken");
string? sectionGetToken = configSection.GetValue<string>("GetToken");

if (string.IsNullOrEmpty(sectionBaseUrl))
if (string.IsNullOrEmpty(sectionPostUrl))
{
throw new Exception("ExternalLeaderboards BaseUrl missing in config");
throw new Exception("ExternalLeaderboards PostUrl missing in config");
}

if (string.IsNullOrEmpty(sectionGetUrl))
{
throw new Exception("ExternalLeaderboards GetUrl missing in config");
}

if (string.IsNullOrEmpty(sectionPostToken))
Expand All @@ -65,7 +72,8 @@ private static void GetExternalLeaderboardsConfig(out string baseUrl, out string
throw new Exception("ExternalLeaderboards GetToken missing in config");
}

baseUrl = sectionBaseUrl;
postUrl = sectionPostUrl;
getUrl = sectionGetUrl;
postToken = sectionPostToken;
getToken = sectionGetToken;
}
Expand Down Expand Up @@ -103,9 +111,7 @@ public static async Task PostMatchResultAsync(AppDbContext db, Lobby lobby)

try
{
GetExternalLeaderboardsConfig(out string baseUrl, out string postToken, out _);

string postUrl = $"{baseUrl.TrimEnd('/')}/matches/ingest";
GetExternalLeaderboardsConfig(out string postUrl, out _, out string postToken, out _);

// Load the match payload
var matchEntry = await Database.MatchHistory.LoadMatchHistoryEntryAsync(db, (long)lobby.MatchID);
Expand Down Expand Up @@ -209,9 +215,9 @@ await retryPolicy.ExecuteAsync(async () =>
{
try
{
GetExternalLeaderboardsConfig(out string baseUrl, out _, out string getToken);
GetExternalLeaderboardsConfig(out _, out string getUrl, out _, out string getToken);

string requestUrl = $"{baseUrl.TrimEnd('/')}/players/{playerId}/leagues/1/rating";
string requestUrl = getUrl.Replace("{playerId}", playerId.ToString());

using (var handler = CreateLeaderboardsHandler())
using (var client = new HttpClient(handler))
Expand Down
5 changes: 3 additions & 2 deletions GenOnlineService/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@
"issuer": null
},
"ExternalLeaderboards": {
"BaseUrl": null,
"PostUrl": null,
"GetUrl": null,
"GetToken": null,
"PostToken": null,
"PostToken": null
}
}
Loading