Skip to content

Commit

Permalink
Revert "Add time gate to Nexus OAuth validation to ensure we don't ge…
Browse files Browse the repository at this point in the history
…nerate an excessive number of requests"

This reverts commit 44b0637.
  • Loading branch information
AlexDickerson committed Dec 29, 2024
1 parent c23c7a7 commit e20fda4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Wabbajack.Networking.NexusApi/NexusApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public class NexusApi
public readonly ITokenProvider<NexusOAuthState> AuthInfo;
private DateTime _lastValidated;
private (ValidateInfo info, ResponseMetadata header) _lastValidatedInfo;
private readonly AsyncLock _authLock = new();
private readonly AsyncLock _authValidationLock = new();
private AsyncLock _authLock = new();

public NexusApi(ITokenProvider<NexusOAuthState> authInfo, ILogger<NexusApi> logger, HttpClient client,
IResource<HttpClient> limiter, ApplicationInfo appInfo, JsonSerializerOptions jsonOptions)
Expand All @@ -54,14 +53,12 @@ public NexusApi(ITokenProvider<NexusOAuthState> authInfo, ILogger<NexusApi> logg
{
var (isApi, code) = await GetAuthInfo();

using var _ = await _authValidationLock.WaitAsync();

if (isApi)
{
var msg = await GenerateMessage(HttpMethod.Get, Endpoints.Validate);
_lastValidatedInfo = await Send<ValidateInfo>(msg, token);
}
else if(_lastValidated < DateTime.Now - TimeSpan.FromMinutes(5)) // We don't want to spam the validate endpoint when starting a modlist download
else
{
var msg = await GenerateMessage(HttpMethod.Get, Endpoints.OAuthValidate);
var (data, header) = await Send<OAuthUserInfo>(msg, token);
Expand All @@ -71,10 +68,9 @@ public NexusApi(ITokenProvider<NexusOAuthState> authInfo, ILogger<NexusApi> logg
Name = data.Name,
};
_lastValidatedInfo = (validateInfo, header);

_lastValidated = DateTime.Now;
}

_lastValidated = DateTime.Now;
return _lastValidatedInfo;
}

Expand Down

0 comments on commit e20fda4

Please sign in to comment.