Fix media placeholders and image cache
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user