2024-03-24 01:31:15 +00:00
|
|
|
namespace BotSharp.Core.Conversations.Services;
|
|
|
|
|
|
|
|
|
|
public partial class ConversationService : IConversationService
|
|
|
|
|
{
|
2024-04-08 03:15:51 +00:00
|
|
|
public async Task UpdateBreakpoint(bool resetStates = false, string? reason = null)
|
2024-03-24 01:31:15 +00:00
|
|
|
{
|
|
|
|
|
var db = _services.GetRequiredService<IBotSharpRepository>();
|
2024-03-26 17:10:34 +00:00
|
|
|
var routingCtx = _services.GetRequiredService<IRoutingContext>();
|
|
|
|
|
var messageId = routingCtx.MessageId;
|
2024-04-08 03:15:51 +00:00
|
|
|
|
|
|
|
|
db.UpdateConversationBreakpoint(_conversationId, new ConversationBreakpoint
|
|
|
|
|
{
|
|
|
|
|
MessageId = messageId,
|
|
|
|
|
Breakpoint = DateTime.UtcNow,
|
|
|
|
|
Reason = reason
|
|
|
|
|
});
|
2024-03-24 13:56:21 +00:00
|
|
|
|
|
|
|
|
// Reset states
|
|
|
|
|
if (resetStates)
|
|
|
|
|
{
|
|
|
|
|
var states = _services.GetRequiredService<IConversationStateService>();
|
|
|
|
|
states.CleanStates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hooks = _services.GetServices<IConversationHook>()
|
|
|
|
|
.OrderBy(x => x.Priority)
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
// Before executing functions
|
|
|
|
|
foreach (var hook in hooks)
|
|
|
|
|
{
|
|
|
|
|
await hook.OnBreakpointUpdated(_conversationId, resetStates);
|
|
|
|
|
}
|
2024-03-24 01:31:15 +00:00
|
|
|
}
|
|
|
|
|
}
|