parent
9c2a26aa82
commit
57c849d0f8
@ -0,0 +1,12 @@
|
||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||
|
||||
// https://discord.com/developers/docs/resources/channel#embed-object-embed-types
|
||||
public enum EmbedKind
|
||||
{
|
||||
Rich,
|
||||
Image,
|
||||
Video,
|
||||
Gifv,
|
||||
Article,
|
||||
Link
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||
|
||||
public partial record GifvEmbedProjection(string Url)
|
||||
{
|
||||
public static GifvEmbedProjection? TryResolve(Embed embed)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(embed.Url))
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(embed.Video?.Url))
|
||||
return null;
|
||||
|
||||
if (!string.Equals(embed.Type, "gifv", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
|
||||
return new GifvEmbedProjection(embed.Url);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using DiscordChatExporter.Core.Discord.Data;
|
||||
using DiscordChatExporter.Core.Discord.Data.Embeds;
|
||||
|
||||
namespace DiscordChatExporter.Core.Exporting.Writers.Html;
|
||||
|
||||
internal static class MessageExtensions
|
||||
{
|
||||
// Message content is hidden if it's a link to an embedded media
|
||||
// https://github.com/Tyrrrz/DiscordChatExporter/issues/682
|
||||
public static bool IsContentHidden(this Message message)
|
||||
{
|
||||
if (message.Embeds.Count != 1)
|
||||
return false;
|
||||
|
||||
var embed = message.Embeds[0];
|
||||
|
||||
return
|
||||
string.Equals(message.Content.Trim(), embed.Url, StringComparison.OrdinalIgnoreCase) &&
|
||||
embed.Kind is EmbedKind.Image or EmbedKind.Gifv;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue