From 78ef7b6c37073737ab600af7a074d363c18ac70d Mon Sep 17 00:00:00 2001 From: Jicheng Lu <103353@smsassist.com> Date: Thu, 28 Mar 2024 10:32:09 -0500 Subject: [PATCH] refine rc options --- .../BotSharp.Abstraction/Messaging/MessageParser.cs | 8 ++++++++ .../Conversations/Services/ConversationStateService.cs | 4 ++-- .../FileRepository/FileRepository.Conversation.cs | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/MessageParser.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/MessageParser.cs index 3707de4a..21431d3f 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/MessageParser.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/MessageParser.cs @@ -45,6 +45,10 @@ public class MessageParser { res = JsonSerializer.Deserialize>(jsonText, options); } + else if (elementType == typeof(ButtonElement).Name) + { + res = JsonSerializer.Deserialize>(jsonText, options); + } } } @@ -80,6 +84,10 @@ public class MessageParser { res = JsonSerializer.Deserialize>(jsonText, options); } + else if (elementType == typeof(ButtonElement).Name) + { + res = JsonSerializer.Deserialize>(jsonText, options); + } } } diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs index 92966564..ee2481bf 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationStateService.cs @@ -118,7 +118,7 @@ public class ConversationStateService : IConversationStateService, IDisposable state.Value.Values.Add(new StateValue { Data = value.Data, - MessageId = !string.IsNullOrEmpty(curMsgId) ? curMsgId : value.MessageId, + MessageId = curMsgId, Active = false, ActiveRounds = value.ActiveRounds, UpdateTime = DateTime.UtcNow @@ -178,7 +178,7 @@ public class ConversationStateService : IConversationStateService, IDisposable value.Values.Add(new StateValue { Data = lastValue.Data, - MessageId = !string.IsNullOrEmpty(curMsgId) ? curMsgId : lastValue.MessageId, + MessageId = curMsgId, Active = false, ActiveRounds = lastValue.ActiveRounds, UpdateTime = utcNow diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs index 16133fc1..bb477391 100644 --- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs +++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Conversation.cs @@ -407,6 +407,11 @@ namespace BotSharp.Core.Repository var utcNow = DateTime.UtcNow; var dir = Path.Combine(_dbSettings.FileRepository, _conversationSettings.DataDir); + if (!Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); + } + if (batchSize <= 0 || batchSize > batchLimit) { batchSize = batchLimit;