hermes-server/Requests/GetPolicies.cs

28 lines
906 B
C#

using HermesSocketServer.Services;
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
{
public class GetPolicies : IRequest
{
public string Name => "get_policies";
public string[] RequiredKeys => [];
private ChannelManager _channels;
private ILogger _logger;
public GetPolicies(ChannelManager channels, ILogger logger)
{
_channels = channels;
_logger = logger;
}
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
{
var channel = _channels.Get(sender);
var results = channel.Policies.Get().Values;
_logger.Information($"Fetched policies for channel [policy size: {results.Count}][channel: {sender}]");
return RequestResult.Successful(results, notifyClientsOnAccount: false);
}
}
}