Disable chat deletion

This commit is contained in:
sevenhill
2026-07-06 22:46:55 +03:00
parent 52ae43c25d
commit 183ec8d90f
11 changed files with 95 additions and 253 deletions
+2 -24
View File
@@ -367,33 +367,11 @@ public sealed class AdminController(
}
[HttpDelete("api/chats/{id:guid}")]
public async Task<IActionResult> DeleteChat(Guid id, [FromQuery] string? pairingCode, CancellationToken cancellationToken)
public IActionResult DeleteChat(Guid id, [FromQuery] string? pairingCode)
{
if (!IsPairingCodeValid(pairingCode)) return Unauthorized();
var chat = await db.Chats
.Include(x => x.Messages)
.ThenInclude(x => x.Attachments)
.FirstOrDefaultAsync(x => x.Id == id, cancellationToken);
if (chat is null)
{
return NotFound();
}
var files = chat.Messages
.SelectMany(x => x.Attachments)
.Select(x => storage.GetPath(x.StorageFileName))
.Where(System.IO.File.Exists)
.ToArray();
db.Chats.Remove(chat);
await db.SaveChangesAsync(cancellationToken);
foreach (var file in files)
{
System.IO.File.Delete(file);
}
return NoContent();
return BadRequest("Chat deletion is disabled because MAX does not remove chats from the web client.");
}
private async Task<AdminStatusDto> BuildStatusAsync(CancellationToken cancellationToken)