Formatting

This commit is contained in:
Tyrrrz 2026-02-27 17:56:29 +02:00
parent 28f26e45fb
commit 675d910ea3
10 changed files with 29 additions and 35 deletions

View file

@ -1,4 +1,4 @@
using DiscordChatExporter.Core.Discord;
using DiscordChatExporter.Core.Discord;
namespace DiscordChatExporter.Cli.Tests.Infra;

View file

@ -19,9 +19,6 @@ public class HtmlForwardSpecs
);
// Assert
message
.Text()
.Should()
.ContainAll("Forwarded", @"¯\_(ツ)_/¯", "December 29, 2025");
message.Text().Should().ContainAll("Forwarded", @"¯\_(ツ)_/¯", "December 29, 2025");
}
}

View file

@ -27,4 +27,3 @@ public class JsonForwardSpecs
forwardedMessage.GetProperty("timestamp").GetString().Should().StartWith("2025-12-29");
}
}

View file

@ -14,8 +14,6 @@ public class PlainTextForwardSpecs
var document = await ExportWrapper.ExportAsPlainTextAsync(ChannelIds.ForwardTestCases);
// Assert
document
.Should()
.ContainAll("{Forwarded Message}", @"¯\_(ツ)_/¯", "December 29, 2025");
document.Should().ContainAll("{Forwarded Message}", @"¯\_(ツ)_/¯", "December 29, 2025");
}
}

View file

@ -9,7 +9,8 @@ public record MessageReference(
MessageReferenceKind Kind,
Snowflake? MessageId,
Snowflake? ChannelId,
Snowflake? GuildId)
Snowflake? GuildId
)
{
public static MessageReference Parse(JsonElement json)
{

View file

@ -15,7 +15,8 @@ public record MessageSnapshot(
string Content,
IReadOnlyList<Attachment> Attachments,
IReadOnlyList<Embed> Embeds,
IReadOnlyList<Sticker> Stickers)
IReadOnlyList<Sticker> Stickers
)
{
public static MessageSnapshot Parse(JsonElement json)
{
@ -23,37 +24,35 @@ public record MessageSnapshot(
json.GetPropertyOrNull("timestamp")?.GetDateTimeOffsetOrNull()
?? DateTimeOffset.MinValue;
var editedTimestamp = json
.GetPropertyOrNull("edited_timestamp")
?.GetDateTimeOffsetOrNull();
var editedTimestamp = json.GetPropertyOrNull("edited_timestamp")?.GetDateTimeOffsetOrNull();
var content = json.GetPropertyOrNull("content")?.GetStringOrNull() ?? "";
var attachments =
json
.GetPropertyOrNull("attachments")
json.GetPropertyOrNull("attachments")
?.EnumerateArrayOrNull()
?.Select(Attachment.Parse)
.ToArray()
?? [];
var embeds =
json
.GetPropertyOrNull("embeds")
?.EnumerateArrayOrNull()
?.Select(Embed.Parse)
.ToArray()
json.GetPropertyOrNull("embeds")?.EnumerateArrayOrNull()?.Select(Embed.Parse).ToArray()
?? [];
var stickers =
json
.GetPropertyOrNull("sticker_items")
json.GetPropertyOrNull("sticker_items")
?.EnumerateArrayOrNull()
?.Select(Sticker.Parse)
.ToArray()
?? [];
return new MessageSnapshot(timestamp,
editedTimestamp, content, attachments, embeds, stickers);
return new MessageSnapshot(
timestamp,
editedTimestamp,
content,
attachments,
embeds,
stickers
);
}
}