Skip to content

Commit

Permalink
can delete span with messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Dec 26, 2024
1 parent f1cc34d commit 1076191
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion src/BE/Controllers/Chats/Chats/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public async Task<IActionResult> 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");
}
Expand Down
6 changes: 0 additions & 6 deletions src/BE/Controllers/Chats/Chats/ChatSpanController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ public async Task<IActionResult> 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();
Expand Down

0 comments on commit 1076191

Please sign in to comment.