[backend/razor] Improve public preview embeds (ISH-512)
Sensitive images are now not embedded. Image embeds now use the correct card type.
This commit is contained in:
parent
6fe4b26019
commit
cb28560dcf
2 changed files with 5 additions and 2 deletions
|
@ -21,4 +21,5 @@ public class PreviewAttachment
|
||||||
public required string Url;
|
public required string Url;
|
||||||
public required string Name;
|
public required string Name;
|
||||||
public required string? Alt;
|
public required string? Alt;
|
||||||
|
public required bool Sensitive;
|
||||||
}
|
}
|
|
@ -61,11 +61,13 @@ else
|
||||||
<PageTitle>Note by @@@_note.User.Username - @_instanceName</PageTitle>
|
<PageTitle>Note by @@@_note.User.Username - @_instanceName</PageTitle>
|
||||||
<HeadContent>
|
<HeadContent>
|
||||||
@{
|
@{
|
||||||
|
var cardType = "summary";
|
||||||
var previewImageUrl = _note.User.AvatarUrl;
|
var previewImageUrl = _note.User.AvatarUrl;
|
||||||
if (ShowMedia && _note.Attachments != null)
|
if (ShowMedia && _note.Attachments != null)
|
||||||
{
|
{
|
||||||
if (_note.Attachments.FirstOrDefault(p => p.MimeType.StartsWith("image/")) is { } img)
|
if (_note.Attachments.FirstOrDefault(p => p.MimeType.StartsWith("image/") && !p.Sensitive) is { } img)
|
||||||
{
|
{
|
||||||
|
cardType = "summary_large_image";
|
||||||
previewImageUrl = img.Url;
|
previewImageUrl = img.Url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +95,7 @@ else
|
||||||
var title = _note.User.RawDisplayName is { } name ? $"{name} (@{username})" : $"@{username}";
|
var title = _note.User.RawDisplayName is { } name ? $"{name} (@{username})" : $"@{username}";
|
||||||
}
|
}
|
||||||
|
|
||||||
<meta name="twitter:card" content="summary">
|
<meta name="twitter:card" content="@cardType">
|
||||||
<meta name="og:site_name" content="@_instanceName">
|
<meta name="og:site_name" content="@_instanceName">
|
||||||
<meta name="og:title" content="@title">
|
<meta name="og:title" content="@title">
|
||||||
<meta name="og:image" content="@previewImageUrl">
|
<meta name="og:image" content="@previewImageUrl">
|
||||||
|
|
Loading…
Add table
Reference in a new issue