From 0932c1c38e7b668a746b9602e1f485c5040a306f Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 8 Nov 2024 16:11:24 +0000 Subject: [PATCH] Fixed redemptions not loading properly --- Hermes/Socket/HermesSocketClient.cs | 8 +------- Hermes/Socket/Requests/GetRedeemableActionsAck.cs | 5 +++-- Hermes/Socket/Requests/GetRedemptionsAck.cs | 8 ++++---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Hermes/Socket/HermesSocketClient.cs b/Hermes/Socket/HermesSocketClient.cs index 5b28d6b..78073ea 100644 --- a/Hermes/Socket/HermesSocketClient.cs +++ b/Hermes/Socket/HermesSocketClient.cs @@ -193,16 +193,10 @@ namespace TwitchChatTTS.Hermes.Socket private async Task FetchRedeemableActions(IEnumerable redemptions) { - var requestId = _callbackManager.GenerateKeyForCallback(new HermesRequestData() - { - Data = new Dictionary() { { "redemptions", redemptions } } - }); - await Send(3, new RequestMessage() { - RequestId = requestId, Type = "get_redeemable_actions", - Data = null + Data = new Dictionary() { { "redemptions", redemptions } } }); } diff --git a/Hermes/Socket/Requests/GetRedeemableActionsAck.cs b/Hermes/Socket/Requests/GetRedeemableActionsAck.cs index 0bb419f..cd9bee9 100644 --- a/Hermes/Socket/Requests/GetRedeemableActionsAck.cs +++ b/Hermes/Socket/Requests/GetRedeemableActionsAck.cs @@ -31,9 +31,10 @@ namespace TwitchChatTTS.Hermes.Socket.Requests return; } - if (requestData["redemptions"] is not IEnumerable redemptions) + IEnumerable? redemptions = JsonSerializer.Deserialize>(requestData["redemptions"].ToString() ?? string.Empty, _options); + if (redemptions == null) { - _logger.Warning("Failed to read the redemptions while updating redemption actions."); + _logger.Warning($"Failed to read the redemptions while updating redemption actions [class type: {requestData["redemptions"].GetType().Name}]"); return; } diff --git a/Hermes/Socket/Requests/GetRedemptionsAck.cs b/Hermes/Socket/Requests/GetRedemptionsAck.cs index 7d88607..ac53b67 100644 --- a/Hermes/Socket/Requests/GetRedemptionsAck.cs +++ b/Hermes/Socket/Requests/GetRedemptionsAck.cs @@ -30,7 +30,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests { hermesRequestData = _callbacks.Take(requestId); if (hermesRequestData == null) - _logger.Warning($"Could not find callback for request [request id: {requestId}][type: {GetType().Name}]"); + _logger.Warning($"Could not find callback for request [request id: {requestId}][type: {Name}]"); else if (hermesRequestData.Data == null) hermesRequestData.Data = new Dictionary(); } @@ -39,11 +39,11 @@ namespace TwitchChatTTS.Hermes.Socket.Requests if (redemptions != null) { _logger.Information($"Redemptions loaded [count: {redemptions.Count()}]"); - if (hermesRequestData != null) + if (hermesRequestData?.Data != null) { - hermesRequestData.Data!.Add("redemptions", redemptions); + hermesRequestData.Data.Add("redemptions", redemptions); - _logger.Debug($"Callback was found for request [request id: {requestId}][type: {GetType().Name}]"); + _logger.Debug($"Callback was found for request [request id: {requestId}][type: {Name}]"); hermesRequestData.Callback?.Invoke(hermesRequestData.Data); } }