2024-01-29 01:33:40 +00:00
|
|
|
namespace BotSharp.Core.Conversations.Services;
|
|
|
|
|
|
|
|
|
|
public partial class ConversationService : IConversationService
|
|
|
|
|
{
|
2024-05-06 22:31:52 +00:00
|
|
|
public async Task<bool> TruncateConversation(string conversationId, string messageId, string? newMessageId = null)
|
2024-01-29 01:33:40 +00:00
|
|
|
{
|
|
|
|
|
var db = _services.GetRequiredService<IBotSharpRepository>();
|
2024-08-08 01:56:29 +00:00
|
|
|
var fileStorage = _services.GetRequiredService<IFileStorageService>();
|
2024-05-06 22:31:52 +00:00
|
|
|
var deleteMessageIds = db.TruncateConversation(conversationId, messageId, cleanLog: true);
|
2024-08-08 01:56:29 +00:00
|
|
|
fileStorage.DeleteMessageFiles(conversationId, deleteMessageIds, messageId, newMessageId);
|
2024-05-06 22:31:52 +00:00
|
|
|
|
2024-12-07 21:47:17 +00:00
|
|
|
var hooks = _services.GetServices<IConversationHook>();
|
2024-03-11 20:32:13 +00:00
|
|
|
foreach (var hook in hooks)
|
|
|
|
|
{
|
|
|
|
|
await hook.OnMessageDeleted(conversationId, messageId);
|
|
|
|
|
}
|
2024-05-06 22:31:52 +00:00
|
|
|
return await Task.FromResult(true);
|
2024-01-29 01:33:40 +00:00
|
|
|
}
|
|
|
|
|
}
|