diff --git a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs index 5b1dfe48..2ffa4364 100644 --- a/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/JsonMessageWriter.cs @@ -138,6 +138,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedAuthor.IconProxyUrl)) + { + _writer.WriteString("iconCanonicalUrl", embedAuthor.IconUrl); + } } _writer.WriteEndObject(); @@ -160,6 +166,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedImage.ProxyUrl)) + { + _writer.WriteString("canonicalUrl", embedImage.Url); + } } _writer.WriteNumber("width", embedImage.Width); @@ -185,6 +197,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedVideo.ProxyUrl)) + { + _writer.WriteString("canonicalUrl", embedVideo.Url); + } } _writer.WriteNumber("width", embedVideo.Width); @@ -212,6 +230,12 @@ internal class JsonMessageWriter(Stream stream, ExportContext context) cancellationToken ) ); + + // Include canonical URL if a proxy URL is being used + if (!string.IsNullOrWhiteSpace(embedFooter.IconProxyUrl)) + { + _writer.WriteString("iconCanonicalUrl", embedFooter.IconUrl); + } } _writer.WriteEndObject(); diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index e0730553..ffeaa745 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,14 @@ embed.Thumbnail?.ProxyUrl ?? embed.Thumbnail?.Url ?? embed.Url; + var embedImageCanonicalUrl = + (embed.Image?.ProxyUrl is not null && embed.Image?.Url is not null) ? embed.Image?.Url : + (embed.Thumbnail?.ProxyUrl is not null && embed.Thumbnail?.Url is not null) ? embed.Thumbnail?.Url : + null; +
- Embedded image + Embedded image
} @@ -457,8 +462,11 @@ embed.Video?.ProxyUrl ?? embed.Video?.Url ?? embed.Url; + var embedVideoCanonicalUrl = + embed.Video?.ProxyUrl is not null && embed.Video?.Url is not null ? embed.Video?.Url : null; +
-
@@ -470,8 +478,11 @@ embed.Video?.ProxyUrl ?? embed.Video?.Url ?? embed.Url; + var embedVideoCanonicalUrl = + embed.Video?.ProxyUrl is not null && embed.Video?.Url is not null ? embed.Video?.Url : null; +
-
@@ -499,7 +510,7 @@
@if (!string.IsNullOrWhiteSpace(embed.Author.IconUrl)) { - Author icon + Author icon } @if (!string.IsNullOrWhiteSpace(embed.Author.Name)) @@ -574,7 +585,7 @@ { } @@ -590,7 +601,7 @@ { } @@ -605,7 +616,7 @@ @* Footer icon *@ @if (!string.IsNullOrWhiteSpace(embed.Footer?.IconUrl)) { - Footer icon + Footer icon }