39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Serilog;
|
|
using TwitchChatTTS.Twitch.Redemptions;
|
|
|
|
namespace TwitchChatTTS.Hermes.Socket.Requests
|
|
{
|
|
public class DeleteRedemptionAck : IRequestAck
|
|
{
|
|
public string Name => "delete_redemption";
|
|
private readonly IRedemptionManager _redemptions;
|
|
private readonly ILogger _logger;
|
|
|
|
public DeleteRedemptionAck(IRedemptionManager redemptions, ILogger logger)
|
|
{
|
|
_redemptions = redemptions;
|
|
_logger = logger;
|
|
}
|
|
|
|
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
|
{
|
|
if (requestData == null)
|
|
{
|
|
_logger.Warning("Request data is null.");
|
|
return;
|
|
}
|
|
|
|
var id = requestData["id"].ToString();
|
|
if (string.IsNullOrEmpty(id))
|
|
{
|
|
_logger.Warning($"Redemption Id is invalid [redemption id: {id}]");
|
|
return;
|
|
}
|
|
|
|
if (_redemptions.RemoveRedemption(id))
|
|
_logger.Information($"Deleted a redemption [redemption id: {id}]");
|
|
else
|
|
_logger.Warning($"Failed to delete a redemption [redemption id: {id}]");
|
|
}
|
|
}
|
|
} |