Compare commits
4 Commits
65522567a5
...
78bab88165
Author | SHA1 | Date | |
---|---|---|---|
78bab88165 | |||
a3f3f90817 | |||
8183678bf0 | |||
23d407b760 |
@ -1,9 +0,0 @@
|
||||
namespace HermesSocketLibrary.Requests
|
||||
{
|
||||
public interface IRequest
|
||||
{
|
||||
string Name { get; }
|
||||
|
||||
Task<RequestResult> Grant(string sender, IDictionary<string, object>? data);
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
using HermesSocketLibrary.Socket.Data;
|
||||
|
||||
namespace HermesSocketLibrary.Requests
|
||||
{
|
||||
public interface IRequestManager
|
||||
{
|
||||
Task<RequestResult> Grant(string sender, RequestMessage? message);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
using HermesSocketLibrary.Socket.Data;
|
||||
using Serilog;
|
||||
|
||||
namespace HermesSocketLibrary.Requests
|
||||
{
|
||||
public class RequestManager : IRequestManager
|
||||
{
|
||||
private readonly IDictionary<string, IRequest> _requests;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
|
||||
public RequestManager(IEnumerable<IRequest> requests, ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
_requests = requests.ToDictionary(r => r.Name, r => r);
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(string sender, RequestMessage? message)
|
||||
{
|
||||
if (message == null || message.Type == null)
|
||||
return new RequestResult(false, null);
|
||||
|
||||
if (!_requests.TryGetValue(message.Type, out IRequest? request) || request == null)
|
||||
{
|
||||
_logger.Warning($"Did not find request type '{message.Type}'.");
|
||||
return new RequestResult(false, null);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return await request.Grant(sender, message.Data);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, $"Failed to grant a request of type '{message.Type}'.");
|
||||
}
|
||||
return new RequestResult(false, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
namespace HermesSocketLibrary.Requests
|
||||
{
|
||||
public class RequestResult
|
||||
{
|
||||
public bool Success;
|
||||
public object? Result;
|
||||
public bool NotifyClientsOnAccount;
|
||||
|
||||
public RequestResult(bool success, object? result, bool notifyClientsOnAccount = true)
|
||||
{
|
||||
Success = success;
|
||||
Result = result;
|
||||
NotifyClientsOnAccount = notifyClientsOnAccount;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HermesSocketLibrary.Socket.Data
|
||||
{
|
||||
public class Connection
|
||||
@ -13,7 +8,7 @@ namespace HermesSocketLibrary.Socket.Data
|
||||
public string AccessToken { get; set; }
|
||||
public string GrantType { get; set; }
|
||||
public string Scope { get; set; }
|
||||
public DateTime ExpiresIn { get; set; }
|
||||
public DateTime ExpiresAt { get; set; }
|
||||
public bool Default { get; set; }
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
|
||||
namespace HermesSocketLibrary.Socket.Data
|
||||
{
|
||||
public class LoginAckMessage
|
||||
@ -9,9 +11,11 @@ namespace HermesSocketLibrary.Socket.Data
|
||||
public bool WebLogin { get; set; }
|
||||
|
||||
public string DefaultTTSVoice { get; set; }
|
||||
public IEnumerable<string> EnabledTTSVoices { get; set; }
|
||||
public IList<string> EnabledTTSVoices { get; set; }
|
||||
public IDictionary<string, string> TTSVoicesAvailable { get; set; }
|
||||
|
||||
public Connection[] Connections { get; set; }
|
||||
public IList<TTSWordFilter> WordFilters { get; set; }
|
||||
|
||||
public IList<Connection> Connections { get; set; }
|
||||
}
|
||||
}
|
12
Socket/Data/PolicyMessage.cs
Normal file
12
Socket/Data/PolicyMessage.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace HermesSocketServer.Models
|
||||
{
|
||||
public class PolicyMessage
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public Guid GroupId { get; set; }
|
||||
public string Path { get; set; }
|
||||
public int Usage { get; set; }
|
||||
public int Span { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user