Fixed a few issues.
This commit is contained in:
@@ -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."));
|
||||
|
||||
Reference in New Issue
Block a user