Fix media placeholders and image cache

This commit is contained in:
sevenhill
2026-07-06 09:10:31 +03:00
parent 9940f9e43c
commit 61d7aae7eb
10 changed files with 275 additions and 16 deletions
@@ -106,6 +106,7 @@ public sealed class ChatsController(
}
var messages = (await query.ToArrayAsync(cancellationToken))
.Where(message => !IsGenericPreviewPlaceholder(message))
.OrderByDescending(x => x.SentAt)
.Take(Math.Clamp(take, 1, 200))
.ToArray();
@@ -121,6 +122,11 @@ public sealed class ChatsController(
return;
}
if (MessageTextSanitizer.IsGenericMediaLabel(preview))
{
return;
}
var previewAt = chat.LastMessageAt.Value;
if (chat.HistoryClearedAt is { } historyClearedAt && previewAt <= historyClearedAt)
{
@@ -202,6 +208,14 @@ public sealed class ChatsController(
return hash.ToString("x8");
}
private static bool IsGenericPreviewPlaceholder(Message message)
{
return message.Direction == MessageDirection.Incoming &&
message.Attachments.Count == 0 &&
message.ExternalId?.StartsWith("preview:", StringComparison.Ordinal) == true &&
MessageTextSanitizer.IsGenericMediaLabel(message.Text);
}
[HttpPost("{chatId:guid}/read")]
public async Task<IActionResult> MarkRead(Guid chatId, CancellationToken cancellationToken)
{