From d3d078735ab21e2c5e4a900cce81226028f04adf Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 18:54:04 +0200 Subject: [PATCH] Preserve original URLs for proxied embed assets (#1456) Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../Exporting/JsonMessageWriter.cs | 4 ++++ .../Exporting/MessageGroupTemplate.cshtml | 23 ++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index 5b1dfe48..1b90ec02 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -138,6 +138,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + _writer.WriteString("iconCanonicalUrl", embedAuthor.IconUrl); } _writer.WriteEndObject(); @@ -160,6 +161,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + _writer.WriteString("canonicalUrl", embedImage.Url); } _writer.WriteNumber("width", embedImage.Width); @@ -185,6 +187,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + _writer.WriteString("canonicalUrl", embedVideo.Url); } _writer.WriteNumber("width", embedVideo.Width); @@ -212,6 +215,7 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + _writer.WriteString("iconCanonicalUrl", embedFooter.IconUrl); } _writer.WriteEndObject(); diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index e0730553..e27fad2b 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -388,7 +388,7 @@
@if (!string.IsNullOrWhiteSpace(embed.Author.IconUrl)) { - Author icon + Author icon } @if (!string.IsNullOrWhiteSpace(embed.Author.Name)) @@ -441,9 +441,12 @@ embed.Thumbnail?.ProxyUrl ?? embed.Thumbnail?.Url ?? embed.Url; + var embedImageCanonicalUrl = + embed.Image?.Url ?? embed.Thumbnail?.Url ?? embed.Url; +
- Embedded image + Embedded image
} @@ -457,8 +460,10 @@ embed.Video?.ProxyUrl ?? embed.Video?.Url ?? embed.Url; + var embedVideoCanonicalUrl = embed.Video?.Url ?? embed.Url; +
-
@@ -470,8 +475,10 @@ embed.Video?.ProxyUrl ?? embed.Video?.Url ?? embed.Url; + var embedVideoCanonicalUrl = embed.Video?.Url ?? embed.Url; +
-
@@ -499,7 +506,7 @@
@if (!string.IsNullOrWhiteSpace(embed.Author.IconUrl)) { - Author icon + Author icon } @if (!string.IsNullOrWhiteSpace(embed.Author.Name)) @@ -574,7 +581,7 @@ { } @@ -590,7 +597,7 @@ { } @@ -605,7 +612,7 @@ @* Footer icon *@ @if (!string.IsNullOrWhiteSpace(embed.Footer?.IconUrl)) { - Footer icon + Footer icon }