Fixed a few issues.

This commit is contained in:
Tom
2025-04-10 17:04:27 +00:00
parent c7904f120d
commit 78b6d4b789
7 changed files with 32 additions and 6 deletions

View File

@@ -23,8 +23,10 @@ namespace HermesSocketServer.Requests
string accessToken = data["access_token"].ToString()!;
string grantType = data["grant_type"].ToString()!;
string scope = data["scope"].ToString()!;
if (!DateTime.TryParse(data["expiration"].ToString()!, out var expiresAt))
if (data["expiration"] == null || !DateTime.TryParse(data["expiration"].ToString(), out var expiresAt))
return Task.FromResult(RequestResult.Failed("Expiration needs to be a date time string."));
var previous = channel.Connections.Get(name);
var connection = new Connection()
{
@@ -36,12 +38,13 @@ namespace HermesSocketServer.Requests
GrantType = grantType,
Scope = scope,
ExpiresAt = expiresAt,
Default = previous?.Default ?? false,
};
bool result = channel.Connections.Set(name, connection);
if (result)
{
_logger.Information($"Added connection to channel [name: {name}][type: {type}][scope: {scope}][expiration: {expiresAt}][channel: {channel.Id}]");
_logger.Information($"Added or updated connection to channel [name: {name}][type: {type}][scope: {scope}][expiration: {expiresAt}][channel: {channel.Id}]");
return Task.FromResult(RequestResult.Successful(connection));
}
return Task.FromResult(RequestResult.Failed("Something went wrong when updating the cache."));