@page "/notes/{id}"
@using Iceshrimp.Backend.Core.Database.Tables
@using Iceshrimp.Backend.Core.Extensions
@model NoteModel
@if (Model.Note == null)
{
Response.StatusCode = 404;
Not found
This note either doesn't exist or is only accessible to authenticated users
}
else
{
async Task RenderNote(string name, Note note)
{
Model.TextContent.TryGetValue(note.Id, out var textContent);
var acct = "@" + note.User.Username + (note.User.IsLocalUser ? "" : "@" + note.User.Host);
var displayName = note.User.DisplayName;
var username = note.User.Username;
var avatarUrl = note.User.AvatarUrl == null || !Model.ShowMedia ? $"/identicon/{note.User.Id}" : note.User.AvatarUrl;
@name by @(displayName ?? username)
@acct
Published at: @note.CreatedAt.ToDisplayString()
@if (note.UpdatedAt != null)
{
Edited at: @note.UpdatedAt.Value.ToDisplayString()
}
if (textContent != null)
{
@if (note.Cw != null)
{
@note.Cw
@Html.Raw(textContent)
}
else
{
@Html.Raw(textContent)
}
}
if (!Model.MediaAttachments.TryGetValue(note.Id, out var files)) return;
if (!Model.ShowMedia)
{
This post has attachments, but this server's configuration prevents them from being displayed here.
return;
}
@foreach (var file in files)
{
if (file.Type.StartsWith("image/"))
{
}
else if (file.Type.StartsWith("video/"))
{
}
else
{
}
}
}
async Task RenderQuoteUrl(string url)
{
var displayUrl = url.StartsWith("https://") ? url[8..] : url[7..];
This post is quoting @displayUrl, but that post either has been deleted or is not publicly visible.
}
ViewData["title"] = $"Note by @{Model.Note.User.Username} - {Model.InstanceName}";
@section head
{
@{
Model.MediaAttachments.TryGetValue(Model.Note.Id, out var attachments);
}
@if (Model.Note.Cw != null)
{
}
else
{
var text = Model.Note.Text;
if (attachments is { Count: > 0 })
{
var attachmentText = $"({attachments.Count} attachments)";
if (string.IsNullOrWhiteSpace(text))
text = attachmentText;
else
text += $"\n{attachmentText}";
}
}
@if (Model.ShowMedia && attachments != null)
{
if (attachments.Any(p => p.Type.StartsWith("image/")))
{
}
}
}
@{
await RenderNote("Note", Model.Note);
if (Model.Note.Renote != null)
await RenderNote("Quote", Model.Note.Renote);
else if (Model.QuoteUrl != null)
await RenderQuoteUrl(Model.QuoteUrl);
}
if (!Model.ShowRemoteReplies)
{
This server's configuration is preventing remotely originating content from being shown. This view may therefore be incomplete.
}
}