Merge pull request #339 from iceljc/features/add-message-delete-event
add message delete event
This commit is contained in:
commit
31805fb413
|
|
@ -67,4 +67,7 @@ public abstract class ConversationHookBase : IConversationHook
|
|||
|
||||
public virtual Task OnUserAgentConnectedInitially(Conversation conversation)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
public virtual Task OnMessageDeleted(string conversationId, string messageId)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,4 +84,12 @@ public interface IConversationHook
|
|||
/// <param name="conversation"></param>
|
||||
/// <returns></returns>
|
||||
Task OnHumanInterventionNeeded(RoleDialogModel message);
|
||||
|
||||
/// <summary>
|
||||
/// Delete message in a conversation
|
||||
/// </summary>
|
||||
/// <param name="conversationId"></param>
|
||||
/// <param name="messageId"></param>
|
||||
/// <returns></returns>
|
||||
Task OnMessageDeleted(string conversationId, string messageId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ public partial class ConversationService : IConversationService
|
|||
{
|
||||
var db = _services.GetRequiredService<IBotSharpRepository>();
|
||||
var isSaved = db.TruncateConversation(conversationId, messageId, true);
|
||||
var hooks = _services.GetServices<IConversationHook>().ToList();
|
||||
foreach (var hook in hooks)
|
||||
{
|
||||
await hook.OnMessageDeleted(conversationId, messageId);
|
||||
}
|
||||
return await Task.FromResult(isSaved);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ namespace BotSharp.Core.Repository
|
|||
public List<string> GetIdleConversations(int batchSize, int messageLimit, int bufferHours)
|
||||
{
|
||||
var ids = new List<string>();
|
||||
var batchLimit = 50;
|
||||
var batchLimit = 100;
|
||||
var utcNow = DateTime.UtcNow;
|
||||
var dir = Path.Combine(_dbSettings.FileRepository, _conversationSettings.DataDir);
|
||||
|
||||
|
|
|
|||
|
|
@ -96,4 +96,14 @@ public class ChatHubConversationHook : ConversationHookBase
|
|||
|
||||
await base.OnResponseGenerated(message);
|
||||
}
|
||||
|
||||
public override async Task OnMessageDeleted(string conversationId, string messageId)
|
||||
{
|
||||
await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageDeleted", new ChatResponseModel
|
||||
{
|
||||
ConversationId = conversationId,
|
||||
MessageId = messageId
|
||||
});
|
||||
await base.OnMessageDeleted(conversationId, messageId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ public partial class MongoRepository
|
|||
public List<string> GetIdleConversations(int batchSize, int messageLimit, int bufferHours)
|
||||
{
|
||||
var page = 1;
|
||||
var batchLimit = 50;
|
||||
var batchLimit = 100;
|
||||
var utcNow = DateTime.UtcNow;
|
||||
var conversationIds = new List<string>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue