From a8c99b3128fa6ea6607a3812d6b2f0aa33350a77 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 23 Sep 2025 15:27:26 +0800 Subject: [PATCH] :sparkles: Editing message previous content diff --- DysonNetwork.Sphere/Chat/ChatService.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DysonNetwork.Sphere/Chat/ChatService.cs b/DysonNetwork.Sphere/Chat/ChatService.cs index de7eda7..b8d1e56 100644 --- a/DysonNetwork.Sphere/Chat/ChatService.cs +++ b/DysonNetwork.Sphere/Chat/ChatService.cs @@ -678,6 +678,10 @@ public partial class ChatService( var isContentChanged = content is not null && content != message.Content; var isAttachmentsChanged = attachmentsId is not null; + string? prevContent = null; + if (isContentChanged) + prevContent = message.Content; + if (content is not null) message.Content = content; @@ -691,9 +695,7 @@ public partial class ChatService( message.ForwardedMessageId = forwardedMessageId; if (attachmentsId is not null) - { await UpdateFileReferencesForMessageAsync(message, attachmentsId); - } // Mark as edited if content or attachments changed if (isContentChanged || isAttachmentsChanged) @@ -718,6 +720,9 @@ public partial class ChatService( UpdatedAt = message.UpdatedAt }; + if (isContentChanged && prevContent is not null) + syncMessage.Meta["previous_content"] = prevContent; + db.ChatMessages.Add(syncMessage); await db.SaveChangesAsync();