|
|
|
@ -10,40 +10,44 @@
|
|
|
|
|
@inherits RazorBlade.HtmlTemplate
|
|
|
|
|
|
|
|
|
|
@functions {
|
|
|
|
|
public required ExportContext ExportContext { get; init; }
|
|
|
|
|
public required ExportContext Context { get; init; }
|
|
|
|
|
|
|
|
|
|
public required IReadOnlyList<Message> Messages { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@{
|
|
|
|
|
ValueTask<string> ResolveAssetUrlAsync(string url) =>
|
|
|
|
|
ExportContext.ResolveAssetUrlAsync(url, CancellationToken);
|
|
|
|
|
Context.ResolveAssetUrlAsync(url, CancellationToken);
|
|
|
|
|
|
|
|
|
|
string FormatDate(DateTimeOffset instant) =>
|
|
|
|
|
ExportContext.FormatDate(instant);
|
|
|
|
|
Context.FormatDate(instant);
|
|
|
|
|
|
|
|
|
|
ValueTask<string> FormatMarkdownAsync(string markdown) =>
|
|
|
|
|
HtmlMarkdownVisitor.FormatAsync(ExportContext, markdown, true, CancellationToken);
|
|
|
|
|
async ValueTask<string> FormatMarkdownAsync(string markdown) =>
|
|
|
|
|
Context.Request.ShouldFormatMarkdown
|
|
|
|
|
? await HtmlMarkdownVisitor.FormatAsync(Context, markdown, true, CancellationToken)
|
|
|
|
|
: markdown;
|
|
|
|
|
|
|
|
|
|
ValueTask<string> FormatEmbedMarkdownAsync(string markdown) =>
|
|
|
|
|
HtmlMarkdownVisitor.FormatAsync(ExportContext, markdown, false, CancellationToken);
|
|
|
|
|
async ValueTask<string> FormatEmbedMarkdownAsync(string markdown) =>
|
|
|
|
|
Context.Request.ShouldFormatMarkdown
|
|
|
|
|
? await HtmlMarkdownVisitor.FormatAsync(Context, markdown, false, CancellationToken)
|
|
|
|
|
: markdown;
|
|
|
|
|
|
|
|
|
|
var firstMessage = Messages.First();
|
|
|
|
|
|
|
|
|
|
var userMember = ExportContext.TryGetMember(firstMessage.Author.Id);
|
|
|
|
|
var userMember = Context.TryGetMember(firstMessage.Author.Id);
|
|
|
|
|
|
|
|
|
|
var userColor = ExportContext.TryGetUserColor(firstMessage.Author.Id);
|
|
|
|
|
var userColor = Context.TryGetUserColor(firstMessage.Author.Id);
|
|
|
|
|
|
|
|
|
|
var userNick = firstMessage.Author.IsBot
|
|
|
|
|
? firstMessage.Author.Name
|
|
|
|
|
: userMember?.Nick ?? firstMessage.Author.Name;
|
|
|
|
|
|
|
|
|
|
var referencedUserMember = firstMessage.ReferencedMessage is not null
|
|
|
|
|
? ExportContext.TryGetMember(firstMessage.ReferencedMessage.Author.Id)
|
|
|
|
|
? Context.TryGetMember(firstMessage.ReferencedMessage.Author.Id)
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
var referencedUserColor = firstMessage.ReferencedMessage is not null
|
|
|
|
|
? ExportContext.TryGetUserColor(firstMessage.ReferencedMessage.Author.Id)
|
|
|
|
|
? Context.TryGetUserColor(firstMessage.ReferencedMessage.Author.Id)
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
var referencedUserNick = firstMessage.ReferencedMessage is not null
|
|
|
|
@ -65,8 +69,8 @@
|
|
|
|
|
{
|
|
|
|
|
// System notifications are grouped even if the message author is different.
|
|
|
|
|
// That's why we have to update the user values with the author of the current message.
|
|
|
|
|
userMember = ExportContext.TryGetMember(message.Author.Id);
|
|
|
|
|
userColor = ExportContext.TryGetUserColor(message.Author.Id);
|
|
|
|
|
userMember = Context.TryGetMember(message.Author.Id);
|
|
|
|
|
userColor = Context.TryGetUserColor(message.Author.Id);
|
|
|
|
|
userNick = message.Author.IsBot
|
|
|
|
|
? message.Author.Name
|
|
|
|
|
: userMember?.Nick ?? message.Author.Name;
|
|
|
|
@ -323,7 +327,7 @@
|
|
|
|
|
|
|
|
|
|
foreach (var inviteCode in inviteCodes)
|
|
|
|
|
{
|
|
|
|
|
var invite = await ExportContext.Discord.TryGetGuildInviteAsync(inviteCode, CancellationToken);
|
|
|
|
|
var invite = await Context.Discord.TryGetGuildInviteAsync(inviteCode, CancellationToken);
|
|
|
|
|
if (invite is null)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|