hermes-server/Requests/DeleteTTSFilter.cs

32 lines
1016 B
C#
Raw Normal View History

2024-12-27 23:31:36 +00:00
using HermesSocketServer.Models;
2024-12-27 22:28:22 +00:00
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
{
public class DeleteTTSFilter : IRequest
{
public string Name => "delete_tts_filter";
public string[] RequiredKeys => ["id"];
private ILogger _logger;
2024-12-27 23:31:36 +00:00
public DeleteTTSFilter(ILogger logger)
2024-12-27 22:28:22 +00:00
{
_logger = logger;
}
2024-12-28 17:24:02 +00:00
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
2024-12-27 22:28:22 +00:00
{
2024-12-27 23:31:36 +00:00
string filterId = data["id"].ToString()!;
var result = channel.Filters.Remove(filterId);
2024-12-27 22:28:22 +00:00
if (result)
{
_logger.Information($"Deleted a TTS filter by id [tts filter id: {filterId}]");
return Task.FromResult(RequestResult.Successful(null));
}
_logger.Warning($"Filter ID does not exist [id: {filterId}]");
return Task.FromResult(RequestResult.Failed("Filter ID does not exist."));
2024-12-27 22:28:22 +00:00
}
}
}