using Serilog; using TwitchChatTTS.Chat.Commands.Limits; using TwitchChatTTS.Chat.Groups; namespace TwitchChatTTS.Hermes.Socket.Requests { public class DeletePolicyAck : IRequestAck { public string Name => "delete_policy"; private readonly IChatterGroupManager _groups; private readonly IUsagePolicy _policies; private readonly ILogger _logger; public DeletePolicyAck(IChatterGroupManager groups, IUsagePolicy policies, ILogger logger) { _groups = groups; _policies = policies; _logger = logger; } public void Acknowledge(string requestId, string json, IDictionary? requestData) { var data = json.Split('/'); if (data.Length != 2) { _logger.Error("Deleting a policy failed: data received is invalid."); return; } var groupId = data[0]; var path = data[1]; var group = _groups.Get(groupId); if (group == null) { _logger.Warning($"Deleting a policy failed: group id does not exist [group id: {groupId}][path: {path}]"); return; } _policies.Remove(group.Name, path); _logger.Information($"Policy has been deleted [group id: {groupId}][path: {path}]"); } } }