mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-29 05:55:21 -04:00
parent
489c786c1e
commit
71876febf8
3 changed files with 7 additions and 5 deletions
|
@ -42,7 +42,7 @@ public record AttachmentSpecs(ExportWrapperFixture ExportWrapper) : IClassFixtur
|
||||||
Snowflake.Parse("885654862656843786")
|
Snowflake.Parse("885654862656843786")
|
||||||
);
|
);
|
||||||
|
|
||||||
var imageUrl = message.QuerySelector("img[alt*=\"attachment\" i]")?.GetAttribute("src");
|
var imageUrl = message.QuerySelector(".chatlog__attachment img")?.GetAttribute("src");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
message.Text().Should().Contain("Image attachment");
|
message.Text().Should().Contain("Image attachment");
|
||||||
|
|
|
@ -13,6 +13,7 @@ public partial record Attachment(
|
||||||
Snowflake Id,
|
Snowflake Id,
|
||||||
string Url,
|
string Url,
|
||||||
string FileName,
|
string FileName,
|
||||||
|
string? Description,
|
||||||
int? Width,
|
int? Width,
|
||||||
int? Height,
|
int? Height,
|
||||||
FileSize FileSize) : IHasId
|
FileSize FileSize) : IHasId
|
||||||
|
@ -37,8 +38,9 @@ public partial record Attachment
|
||||||
var width = json.GetPropertyOrNull("width")?.GetInt32OrNull();
|
var width = json.GetPropertyOrNull("width")?.GetInt32OrNull();
|
||||||
var height = json.GetPropertyOrNull("height")?.GetInt32OrNull();
|
var height = json.GetPropertyOrNull("height")?.GetInt32OrNull();
|
||||||
var fileName = json.GetProperty("filename").GetNonNullString();
|
var fileName = json.GetProperty("filename").GetNonNullString();
|
||||||
|
var description = json.GetPropertyOrNull("description")?.GetNonWhiteSpaceStringOrNull();
|
||||||
var fileSize = json.GetProperty("size").GetInt64().Pipe(FileSize.FromBytes);
|
var fileSize = json.GetProperty("size").GetInt64().Pipe(FileSize.FromBytes);
|
||||||
|
|
||||||
return new Attachment(id, url, fileName, width, height, fileSize);
|
return new Attachment(id, url, fileName, description, width, height, fileSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -158,19 +158,19 @@
|
||||||
@if (attachment.IsImage)
|
@if (attachment.IsImage)
|
||||||
{
|
{
|
||||||
<a href="@await ResolveUrlAsync(attachment.Url)">
|
<a href="@await ResolveUrlAsync(attachment.Url)">
|
||||||
<img class="chatlog__attachment-media" src="@await ResolveUrlAsync(attachment.Url)" alt="Image attachment" title="Image: @attachment.FileName (@attachment.FileSize)" loading="lazy">
|
<img class="chatlog__attachment-media" src="@await ResolveUrlAsync(attachment.Url)" alt="@(attachment.Description ?? "Image attachment")" title="Image: @attachment.FileName (@attachment.FileSize)" loading="lazy">
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
else if (attachment.IsVideo)
|
else if (attachment.IsVideo)
|
||||||
{
|
{
|
||||||
<video class="chatlog__attachment-media" controls>
|
<video class="chatlog__attachment-media" controls>
|
||||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Video attachment" title="Video: @attachment.FileName (@attachment.FileSize)">
|
<source src="@await ResolveUrlAsync(attachment.Url)" alt="@(attachment.Description ?? "Video attachment")" title="Video: @attachment.FileName (@attachment.FileSize)">
|
||||||
</video>
|
</video>
|
||||||
}
|
}
|
||||||
else if (attachment.IsAudio)
|
else if (attachment.IsAudio)
|
||||||
{
|
{
|
||||||
<audio class="chatlog__attachment-media" controls>
|
<audio class="chatlog__attachment-media" controls>
|
||||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Audio attachment" title="Audio: @attachment.FileName (@attachment.FileSize)">
|
<source src="@await ResolveUrlAsync(attachment.Url)" alt="@(attachment.Description ?? "Audio attachment")" title="Audio: @attachment.FileName (@attachment.FileSize)">
|
||||||
</audio>
|
</audio>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue