Added delete policy request
This commit is contained in:
parent
e7b06f1634
commit
aac73563d0
27
Requests/DeletePolicy.cs
Normal file
27
Requests/DeletePolicy.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using HermesSocketServer.Services;
|
||||
using ILogger = Serilog.ILogger;
|
||||
|
||||
namespace HermesSocketServer.Requests
|
||||
{
|
||||
public class DeletePolicy : IRequest
|
||||
{
|
||||
public string Name => "delete_policy";
|
||||
public string[] RequiredKeys => ["id"];
|
||||
private ChannelManager _channels;
|
||||
private ILogger _logger;
|
||||
|
||||
public DeletePolicy(ChannelManager channels, ILogger logger)
|
||||
{
|
||||
_channels = channels;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
||||
{
|
||||
var channel = _channels.Get(sender);
|
||||
channel.Policies.Remove(data!["id"].ToString());
|
||||
_logger.Information($"Deleted a policy by id [policy id: {data["id"]}]");
|
||||
return RequestResult.Successful(null);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user