add message delete event
This commit is contained in:
parent
656b533523
commit
6c1cebe87b
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public static class BotSharpOpenApiExtensions
|
|||
bool enableValidation)
|
||||
{
|
||||
services.AddScoped<IUserIdentity, UserIdentity>();
|
||||
services.AddHostedService<ConversationTimeoutService>();
|
||||
//services.AddHostedService<ConversationTimeoutService>();
|
||||
|
||||
// Add bearer authentication
|
||||
var schema = "MIXED_SCHEME";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue