Fix a lot of the analyzer warnings too
This commit is contained in:
@@ -179,7 +179,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
|
||||
|
||||
if (token.IsCancellationRequested) break;
|
||||
|
||||
_mareHub = await _hubFactory.GetOrCreate(token);
|
||||
_mareHub = await _hubFactory.GetOrCreate(token).ConfigureAwait(false);
|
||||
InitializeApiHooks();
|
||||
|
||||
await _mareHub.StartAsync(token).ConfigureAwait(false);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class HubFactory : MediatorSubscriberBase
|
||||
{
|
||||
if (!_isDisposed && _instance != null) return _instance;
|
||||
|
||||
_cachedConfig = await ResolveHubConfig();
|
||||
_cachedConfig = await ResolveHubConfig().ConfigureAwait(false);
|
||||
_cachedConfigFor = _serverConfigurationManager.CurrentApiUrl;
|
||||
|
||||
return BuildHubConnection(_cachedConfig, ct);
|
||||
@@ -71,7 +71,7 @@ public class HubFactory : MediatorSubscriberBase
|
||||
|
||||
HubConnectionConfig defaultConfig;
|
||||
|
||||
if (_cachedConfig != null && _serverConfigurationManager.CurrentApiUrl == _cachedConfigFor)
|
||||
if (_cachedConfig != null && _serverConfigurationManager.CurrentApiUrl.Equals(_cachedConfigFor, StringComparison.Ordinal))
|
||||
{
|
||||
defaultConfig = _cachedConfig;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class HubFactory : MediatorSubscriberBase
|
||||
};
|
||||
}
|
||||
|
||||
if (_serverConfigurationManager.CurrentApiUrl == ApiController.LoporritServiceUri)
|
||||
if (_serverConfigurationManager.CurrentApiUrl.Equals(ApiController.LoporritServiceUri, StringComparison.Ordinal))
|
||||
defaultConfig.HubUrl = ApiController.LoporritServiceHubUri;
|
||||
|
||||
string jsonResponse;
|
||||
@@ -126,7 +126,7 @@ public class HubFactory : MediatorSubscriberBase
|
||||
|
||||
var contentType = response.Content.Headers.ContentType?.MediaType;
|
||||
|
||||
if (contentType == null || contentType != "application/json")
|
||||
if (contentType == null || !contentType.Equals("application/json", StringComparison.Ordinal))
|
||||
return defaultConfig;
|
||||
|
||||
jsonResponse = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
@@ -21,7 +21,7 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
|
||||
private readonly ILogger<TokenProvider> _logger;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly ConcurrentDictionary<JwtIdentifier, string> _tokenCache = new();
|
||||
private readonly ConcurrentDictionary<string, string?> _wellKnownCache = new();
|
||||
private readonly ConcurrentDictionary<string, string?> _wellKnownCache = new(StringComparer.Ordinal);
|
||||
|
||||
public TokenProvider(ILogger<TokenProvider> logger, ServerConfigurationManager serverManager, DalamudUtilService dalamudUtil, MareMediator mareMediator)
|
||||
{
|
||||
@@ -70,22 +70,20 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
|
||||
.Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase)));
|
||||
var secretKey = _serverManager.GetSecretKey(out _)!;
|
||||
var auth = secretKey.GetHash256();
|
||||
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("auth", auth),
|
||||
new KeyValuePair<string, string>("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)),
|
||||
}), token).ConfigureAwait(false);
|
||||
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent([
|
||||
new("auth", auth),
|
||||
new("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)),
|
||||
]), token).ConfigureAwait(false);
|
||||
|
||||
if (result.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
tokenUri = MareAuth.AuthFullPath(new Uri(_serverManager.CurrentApiUrl
|
||||
.Replace("wss://", "https://", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase)));
|
||||
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("auth", auth),
|
||||
new KeyValuePair<string, string>("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)),
|
||||
}), token).ConfigureAwait(false);
|
||||
result = await _httpClient.PostAsync(tokenUri, new FormUrlEncodedContent([
|
||||
new("auth", auth),
|
||||
new("charaIdent", await _dalamudUtil.GetPlayerNameHashedAsync().ConfigureAwait(false)),
|
||||
]), token).ConfigureAwait(false);
|
||||
|
||||
var textResponse = await result.Content.ReadAsStringAsync(token).ConfigureAwait(false) ?? string.Empty;
|
||||
result.EnsureSuccessStatusCode();
|
||||
|
||||
Reference in New Issue
Block a user