From 1076191b8c790ae826ae6974e900610de0501b4d Mon Sep 17 00:00:00 2001 From: sdcb Date: Thu, 26 Dec 2024 12:46:42 +0800 Subject: [PATCH] can delete span with messages --- src/BE/Controllers/Chats/Chats/ChatController.cs | 2 +- src/BE/Controllers/Chats/Chats/ChatSpanController.cs | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/BE/Controllers/Chats/Chats/ChatController.cs b/src/BE/Controllers/Chats/Chats/ChatController.cs index e93f8af5..45af307e 100644 --- a/src/BE/Controllers/Chats/Chats/ChatController.cs +++ b/src/BE/Controllers/Chats/Chats/ChatController.cs @@ -190,7 +190,7 @@ public async Task ChatPrivate( MessageLiteDto[] systemMessages = GetSystemMessages(chat, req.Spans, existingMessages, isEmptyChat); // ensure chat.ChatSpan contains all span ids that in request, otherwise return error - if (req.Spans!.Any(x => !chat.ChatSpans.Any(y => y.SpanId == x.Id))) + if (req.Spans.Any(x => !chat.ChatSpans.Any(y => y.SpanId == x.Id))) { return BadRequest("Invalid span id"); } diff --git a/src/BE/Controllers/Chats/Chats/ChatSpanController.cs b/src/BE/Controllers/Chats/Chats/ChatSpanController.cs index 2cf1fa79..fe5f68de 100644 --- a/src/BE/Controllers/Chats/Chats/ChatSpanController.cs +++ b/src/BE/Controllers/Chats/Chats/ChatSpanController.cs @@ -139,12 +139,6 @@ public async Task DeleteChatSpan(string encryptedChatId, byte spa return NotFound(); } - bool hasMessages = await db.Messages.AnyAsync(x => x.ChatId == chatId && x.SpanId == spanId, cancellationToken); - if (hasMessages) - { - return BadRequest("Cannot delete span with messages"); - } - db.ChatSpans.Remove(span); await db.SaveChangesAsync(cancellationToken); return NoContent();