diff --git a/Requests/DeletePolicy.cs b/Requests/DeletePolicy.cs new file mode 100644 index 0000000..f879261 --- /dev/null +++ b/Requests/DeletePolicy.cs @@ -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 Grant(string sender, IDictionary? 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); + } + } +} \ No newline at end of file