R4 the client catches up: follow requests, followers, downvotes, dismissing, filtering a post, quote policies, statistics in detail
Build / Build (push) Successful in 1m8s
Build / Build (push) Successful in 1m8s
Follow requests answered on the persona's own profile and from the Notifications tab; its followers and the accounts it follows listed there, a follower removed (asked first). Downvotes on threadiverse posts, after the public-vote notice. A notification dismissed from its line. "Filter this post" from a card's menu, and the Filters page showing the posts a filter holds. Who may quote the persona's own posts, and revoking a quote of one. Statistics: a server in detail with "describe again", the ledger's events, the server's own days. The composer deletes an upload taken out before posting. MediaType.Documents goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WpVCoDeM1qUTRp4fXQdfof
This commit is contained in:
1 parent
b731d8c8c0
commit
b8d7858acb
25 files changed
+1543
-61
No files matched your search
@@ -0,0 +1,58 @@
|
||||
@inherits LocalizableComponentBase
|
||||
|
||||
@* The federation ledger's events, newest first (ViewInteractionEvent): what was received, delivered or fetched and how
|
||||
it ended, never who. Channels and outcomes show as the ledger keys them, like the statistics' counters. In the
|
||||
statistics' Events section and in a server's detail. *@
|
||||
<DTable Size="DSize.Xs" Zebra="true" WrapperClass="max-h-[28rem] rounded-xl neo-inset neo-2xs" data-statistics-events-table data-scroll-x>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@Localizer["When"]</th>
|
||||
@if (ShowHost)
|
||||
{
|
||||
<th>@Localizer["server"]</th>
|
||||
}
|
||||
<th>@Localizer["Channel"]</th>
|
||||
<th>@Localizer["Activity"]</th>
|
||||
<th>@Localizer["Outcome"]</th>
|
||||
<th>@Localizer["Reason"]</th>
|
||||
<th class="text-right">HTTP</th>
|
||||
<th class="text-right">ms</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var happened in Events)
|
||||
{
|
||||
<tr data-statistics-event="@happened.Channel" data-outcome="@happened.Outcome">
|
||||
<td class="whitespace-nowrap" title="@NerdRow.Time(happened.At)">@happened.At.ToLocalTime().ToString(SUtility.dateTimeFormatExt)</td>
|
||||
@if (ShowHost)
|
||||
{
|
||||
<td class="max-w-40 truncate" title="@happened.Host">@happened.Host</td>
|
||||
}
|
||||
<td>@happened.Channel</td>
|
||||
<td class="max-w-48 truncate" title="@happened.Object">@happened.Activity</td>
|
||||
<td>
|
||||
<DBadge Size="DSize.Xs" Color="@OutcomeColor(happened.Outcome)">@happened.Outcome</DBadge>
|
||||
</td>
|
||||
<td class="max-w-48 truncate" title="@happened.Reason">@happened.Reason</td>
|
||||
<td class="text-right tabular-nums">@happened.Status</td>
|
||||
<td class="text-right tabular-nums">@happened.LatencyMs</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</DTable>
|
||||
|
||||
@code {
|
||||
[Parameter, EditorRequired] public List<ViewInteractionEvent> Events { get; set; } = [];
|
||||
/// <summary>A column for the server, where the events are of many.</summary>
|
||||
[Parameter] public bool ShowHost { get; set; } = true;
|
||||
|
||||
protected override void OnInitialized() => IsLoading = false;
|
||||
|
||||
static DColor OutcomeColor(string outcome) => outcome switch
|
||||
{
|
||||
"ok" or "accepted" => DColor.Success,
|
||||
"queued" or "deferred" or "retry" => DColor.Warning,
|
||||
"failed" or "dead" or "refused" or "rejected" or "dropped" => DColor.Error,
|
||||
_ => DColor.None
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
@inherits LocalizableComponentBase
|
||||
|
||||
@* One server of the federation statistics (/clientapi/admin/statistics/hosts/{host}), opened from its row: what it says
|
||||
of itself and what PrivaPub knows of its deliveries (as nerd rows, by their field names), its days with the main
|
||||
counters (newest first; a live day is today's, or one not rolled up yet), and its latest events. "Describe again"
|
||||
asks PrivaPub to read its NodeInfo and instance description anew. Counted per server, never per account. *@
|
||||
<DModal Placement="DModalPlacement.ResponsiveBottom" IsOpen="true" IsOpenChanged="Closed" CloseText="@Localizer["Close"]" BoxClass="md:w-11/12 md:max-w-4xl"
|
||||
data-host-detail="@HostName">
|
||||
<Heading><span class="break-all">@HostName</span></Heading>
|
||||
<ChildContent>
|
||||
<div class="flex flex-col gap-4 mt-3">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<DButton Size="DSize.Sm" Disabled="@(IsDefaultDisabled || isDescribing)" OnClick="Describe" data-host-describe>
|
||||
<i class="ion-md-refresh" aria-hidden="true"></i><span>@Localizer["Describe again"]</span>
|
||||
</DButton>
|
||||
</div>
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
<p class="flex items-center gap-2"><DLoading Variant="DLoadingVariant.Dots" LabelText="@Localizer["loading"]" />@Localizer["loading"]</p>
|
||||
}
|
||||
else if (detail is null)
|
||||
{
|
||||
<p class="text-sm opacity-70">@Localizer["The statistics could not be read."]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (detail.Instance is { } instance)
|
||||
{
|
||||
<NerdRows Rows="InstanceRows(instance)" />
|
||||
}
|
||||
|
||||
<DTable Size="DSize.Xs" Zebra="true" WrapperClass="max-h-72 rounded-xl neo-inset neo-2xs" data-host-days data-scroll-x>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@Localizer["Day"]</th>
|
||||
<th class="text-right">@Localizer["Received"]</th>
|
||||
<th class="text-right">@Localizer["In"]</th>
|
||||
<th class="text-right">@Localizer["Out"]</th>
|
||||
<th class="text-right">@Localizer["Failures"]</th>
|
||||
<th class="text-right">@Localizer["Accounts"]</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var day in detail.Days.OrderByDescending(d => d.Day))
|
||||
{
|
||||
<tr data-host-day="@NerdRow.Time(day.Day)">
|
||||
<td class="whitespace-nowrap">
|
||||
@day.Day.ToString(SUtility.dateTimeFormat)
|
||||
@if (day.Live)
|
||||
{
|
||||
<DBadge Size="DSize.Xs" Color="DColor.Info">@Localizer["live"]</DBadge>
|
||||
}
|
||||
</td>
|
||||
<td class="text-right tabular-nums">@Channel(day.Counters, "recv")</td>
|
||||
<td class="text-right tabular-nums">@Channel(day.Counters, "in")</td>
|
||||
<td class="text-right tabular-nums">@Channel(day.Counters, "out")</td>
|
||||
<td class="text-right tabular-nums">@Failures(day.Counters)</td>
|
||||
<td class="text-right tabular-nums">@day.Accounts</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</DTable>
|
||||
|
||||
@if (detail.Events.Count > 0)
|
||||
{
|
||||
<b class="text-sm">@Localizer["Last events"]</b>
|
||||
<EventsTable Events="detail.Events" ShowHost="false" />
|
||||
}
|
||||
<p class="text-xs opacity-70">@detail.Attribution</p>
|
||||
}
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DModal>
|
||||
|
||||
@code {
|
||||
[Inject] AdminService AdminService { get; set; }
|
||||
|
||||
[Parameter, EditorRequired] public string HostName { get; set; }
|
||||
/// <summary>How many days back its days go.</summary>
|
||||
[Parameter] public int Days { get; set; } = 30;
|
||||
[Parameter] public EventCallback OnClosed { get; set; }
|
||||
|
||||
ViewHostDetail detail;
|
||||
bool isDescribing;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (CascadingState.IsOffline)
|
||||
{
|
||||
WhenOnline(LoadData);
|
||||
StartOnlinePolling();
|
||||
IsLoading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
await LoadData();
|
||||
IsLoading = false;
|
||||
}
|
||||
|
||||
async Task LoadData() => detail = await AdminService.Host(HostName, Days);
|
||||
|
||||
async Task Describe()
|
||||
{
|
||||
isDescribing = true;
|
||||
var result = await AdminService.Describe(HostName);
|
||||
isDescribing = false;
|
||||
if (result.IsInvalid)
|
||||
{
|
||||
Toast.AddResponseError(result);
|
||||
return;
|
||||
}
|
||||
|
||||
Toast.AddResponseSuccess(Localizer["PrivaPub will read what {0} says of itself again.", HostName]);
|
||||
}
|
||||
|
||||
/// <summary>A channel's counters of a day (recv: deliveries to PrivaPub's inboxes; in: activities taken in; out: sent).</summary>
|
||||
static long Channel(Dictionary<string, long> counters, string channel) =>
|
||||
counters.Where(c => c.Key.StartsWith(channel + ":", StringComparison.Ordinal)).Sum(c => c.Value);
|
||||
|
||||
// the deliveries out that failed, are retried or were given up, as the servers table counts them
|
||||
static long Failures(Dictionary<string, long> counters) =>
|
||||
counters.Where(c => c.Key.Split(':') is { Length: >= 4 } parts && parts[0] == "out" && parts[3] is "retry" or "dead" or "failed").Sum(c => c.Value);
|
||||
|
||||
static IEnumerable<NerdRow> InstanceRows(ViewHostInstance instance)
|
||||
{
|
||||
yield return NerdRow.Of("software", $"{instance.Software} {instance.SoftwareVersion}".Trim());
|
||||
yield return NerdRow.Of("nodeName", instance.NodeName);
|
||||
yield return NerdRow.Of("title", instance.Title);
|
||||
yield return NerdRow.Of("nodeDescription", instance.NodeDescription);
|
||||
yield return NerdRow.Of("openRegistrations", instance.OpenRegistrations);
|
||||
yield return NerdRow.Of("registrationMode", instance.RegistrationMode);
|
||||
yield return NerdRow.Of("usersTotal", instance.UsersTotal);
|
||||
yield return NerdRow.Of("usersActiveMonth", instance.UsersActiveMonth);
|
||||
yield return NerdRow.Of("localPosts", instance.LocalPosts);
|
||||
yield return NerdRow.Of("languages", instance.Languages.Count > 0 ? string.Join(", ", instance.Languages) : null);
|
||||
yield return NerdRow.Of("seen", instance.Seen);
|
||||
yield return NerdRow.Of("firstSeenAt", instance.FirstSeenAt);
|
||||
yield return NerdRow.Of("lastSeenAt", instance.LastSeenAt);
|
||||
yield return NerdRow.Of("describedAt", instance.DescribedAt);
|
||||
yield return NerdRow.Of("descriptionError", instance.DescriptionError);
|
||||
yield return NerdRow.Of("lastSuccessAt", instance.LastSuccessAt);
|
||||
yield return NerdRow.Of("lastFailureAt", instance.LastFailureAt);
|
||||
yield return NerdRow.Of("lastError", instance.LastError);
|
||||
yield return NerdRow.Of("consecutiveFailures", instance.ConsecutiveFailures > 0 ? instance.ConsecutiveFailures : null);
|
||||
yield return NerdRow.Of("unavailableUntil", instance.UnavailableUntil);
|
||||
yield return NerdRow.Of("place", string.Join(", ", new[] { instance.City, instance.Country }.Where(p => !string.IsNullOrWhiteSpace(p))) is { Length: > 0 } place ? place : null);
|
||||
yield return NerdRow.Of("asn", instance.Asn is { } asn ? $"AS{asn} {instance.AsnOrg}".Trim() : null);
|
||||
yield return NerdRow.Of("cdn", instance.Cdn);
|
||||
yield return NerdRow.Of("instanceApi", instance.InstanceApi);
|
||||
yield return NerdRow.Of("sourceUrl", instance.SourceUrl);
|
||||
}
|
||||
|
||||
Task Closed(bool open) => open ? Task.CompletedTask : OnClosed.InvokeAsync();
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
@inherits LocalizableComponentBase
|
||||
|
||||
@* PrivaPub's federation statistics (/clientapi/admin/statistics): the last days at a glance, the servers exchanged with
|
||||
(by traffic, failures, latency or name, 50 a page) and how far the crawler got. Counted per server, never per account. *@
|
||||
(by traffic, failures, latency or name, 50 a page; a server's name opens its detail, HostDetailDialog), how far the
|
||||
crawler got, the ledger's events (by server, channel and outcome, 100 at a time, older ones from the last one's time)
|
||||
and the server's own days (its client API, the documents it served, its ledger). Counted per server, never per
|
||||
account. *@
|
||||
<div class="flex flex-col gap-4 w-full" data-statistics>
|
||||
<div class="flex flex-wrap gap-2 items-end">
|
||||
<label class="flex flex-col gap-1 text-sm">
|
||||
@@ -87,7 +90,10 @@
|
||||
@foreach (var host in hosts.Hosts)
|
||||
{
|
||||
<tr data-statistics-host="@host.Host">
|
||||
<td class="max-w-48 truncate">@host.Host</td>
|
||||
<td class="max-w-48">
|
||||
<button type="button" class="link link-hover block max-w-full truncate text-left pointer-coarse:py-3.5" title="@host.Host"
|
||||
@onclick="() => openHost = host.Host" data-statistics-host-open>@host.Host</button>
|
||||
</td>
|
||||
<td>@host.Software @host.Version</td>
|
||||
<td class="text-right tabular-nums">@host.In</td>
|
||||
<td class="text-right tabular-nums">@host.Out</td>
|
||||
@@ -116,6 +122,11 @@
|
||||
<p class="text-xs opacity-70">@hosts.Attribution</p>
|
||||
}
|
||||
|
||||
@if (openHost is { } detailHost)
|
||||
{
|
||||
<HostDetailDialog HostName="@detailHost" Days="days" OnClosed="() => openHost = null" />
|
||||
}
|
||||
|
||||
@if (crawler is not null)
|
||||
{
|
||||
<div class="flex flex-col gap-1 text-xs" data-statistics-crawler>
|
||||
@@ -141,6 +152,99 @@
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="flex flex-col gap-2" data-statistics-events>
|
||||
<b class="text-sm">@Localizer["Events"]</b>
|
||||
<div class="flex flex-wrap gap-2 items-end">
|
||||
<label class="flex flex-col gap-1 text-sm">
|
||||
<span>@Localizer["server"]</span>
|
||||
<DInput TValue="string" Size="DSize.Sm" @bind-Value="eventsHost" @bind-Value:after="ReloadEvents" autocomplete="off" maxlength="253"
|
||||
placeholder="@Localizer["A server, e.g. example.social"]" data-statistics-events-host />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-sm">
|
||||
<span>@Localizer["Channel"]</span>
|
||||
<DSelect TValue="string" Size="DSize.Sm" Value="eventsChannel" ValueChanged="ChangeChannel" ValueExpression="() => eventsChannel"
|
||||
data-statistics-events-channel>
|
||||
<option value="">@Localizer["All"]</option>
|
||||
@foreach (var channel in EventChannels)
|
||||
{
|
||||
<option value="@channel">@channel</option>
|
||||
}
|
||||
</DSelect>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 text-sm">
|
||||
<span>@Localizer["Outcome"]</span>
|
||||
<DSelect TValue="string" Size="DSize.Sm" Value="eventsOutcome" ValueChanged="ChangeOutcome" ValueExpression="() => eventsOutcome"
|
||||
data-statistics-events-outcome>
|
||||
<option value="">@Localizer["All"]</option>
|
||||
@foreach (var outcome in EventOutcomes)
|
||||
{
|
||||
<option value="@outcome">@outcome</option>
|
||||
}
|
||||
</DSelect>
|
||||
</label>
|
||||
</div>
|
||||
@if (events.Count == 0)
|
||||
{
|
||||
<p class="text-xs opacity-70" data-statistics-events-empty>@Localizer["Empty"]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<EventsTable Events="events" />
|
||||
}
|
||||
@if (hasMoreEvents)
|
||||
{
|
||||
<DButton Size="DSize.Sm" class="self-center" Disabled="@(IsDefaultDisabled || isLoadingMore)" OnClick="MoreEvents" data-statistics-events-more>
|
||||
@if (isLoadingMore)
|
||||
{
|
||||
<DLoading Size="DSize.Xs" LabelText="@Localizer["loading"]" />
|
||||
}
|
||||
<span>@Localizer["Load more"]</span>
|
||||
</DButton>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2" data-statistics-server>
|
||||
<b class="text-sm">@Localizer["Server days"]</b>
|
||||
@if (serverDays.Count == 0)
|
||||
{
|
||||
<p class="text-xs opacity-70">@Localizer["Empty"]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<DTable Size="DSize.Xs" Zebra="true" WrapperClass="max-h-[28rem] rounded-xl neo-inset neo-2xs" data-scroll-x>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@Localizer["Day"]</th>
|
||||
<th class="text-right">@Localizer["Client API"]</th>
|
||||
<th class="text-right">4xx</th>
|
||||
<th class="text-right">5xx</th>
|
||||
<th class="text-right">@Localizer["Served"]</th>
|
||||
<th class="text-right" title="@Localizer["written / dropped / failed"]">@Localizer["Ledger"]</th>
|
||||
<th class="text-right">@Localizer["Accounts"]</th>
|
||||
<th class="text-right"><span class="capitalize">@Localizer["servers"]</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var day in Enumerable.Reverse(serverDays))
|
||||
{
|
||||
<tr data-statistics-server-day="@NerdRow.Time(day.Day)">
|
||||
<td class="whitespace-nowrap">@day.Day.ToString(SUtility.dateTimeFormat)</td>
|
||||
<td class="text-right tabular-nums">@ClientRequests(day, null)</td>
|
||||
<td class="text-right tabular-nums">@ClientRequests(day, ":4xx")</td>
|
||||
<td class="text-right tabular-nums">@ClientRequests(day, ":5xx")</td>
|
||||
<td class="text-right tabular-nums">@day.Served.Values.Sum()</td>
|
||||
<td class="text-right tabular-nums whitespace-nowrap" title="@Localizer["written / dropped / failed"]">
|
||||
@day.LedgerWritten / @day.LedgerDropped / @day.LedgerFailed
|
||||
</td>
|
||||
<td class="text-right tabular-nums">@day.Accounts</td>
|
||||
<td class="text-right tabular-nums">@day.Hosts</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</DTable>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -148,11 +252,24 @@
|
||||
[Inject] AdminService AdminService { get; set; }
|
||||
|
||||
const int PageSize = 50;
|
||||
const int EventsPageSize = 100;
|
||||
// the ledger's channels and outcomes, as it keys them
|
||||
static readonly string[] EventChannels = ["recv", "in", "out", "http", "preview", "crawl"];
|
||||
static readonly string[] EventOutcomes = ["queued", "accepted", "refused", "dropped", "rejected", "ok", "failed", "deferred", "retry", "dead"];
|
||||
static readonly int[] Periods = [1, 7, 30, 90];
|
||||
|
||||
ViewStatisticsOverview overview;
|
||||
ViewHostsPage hosts;
|
||||
ViewCrawler crawler;
|
||||
List<ViewInteractionEvent> events = [];
|
||||
List<ViewServerDay> serverDays = [];
|
||||
// the server whose detail is open
|
||||
string openHost;
|
||||
string eventsHost;
|
||||
string eventsChannel;
|
||||
string eventsOutcome;
|
||||
bool hasMoreEvents;
|
||||
bool isLoadingMore;
|
||||
int days = 30;
|
||||
string sort = "traffic";
|
||||
int page = 1;
|
||||
@@ -179,10 +296,53 @@
|
||||
}
|
||||
|
||||
async Task LoadData()
|
||||
{
|
||||
await LoadDays();
|
||||
crawler = await AdminService.Crawler();
|
||||
await ReloadEvents();
|
||||
}
|
||||
|
||||
// what the period chosen shows
|
||||
async Task LoadDays()
|
||||
{
|
||||
overview = await AdminService.Overview(days);
|
||||
hosts = await AdminService.Hosts(days, sort, page);
|
||||
crawler = await AdminService.Crawler();
|
||||
serverDays = await AdminService.ServerDays(days);
|
||||
}
|
||||
|
||||
// the client API's requests of a day, those of one status class (":4xx") or all
|
||||
static long ClientRequests(ViewServerDay day, string statusClass) =>
|
||||
day.Client.Where(c => c.Key.EndsWith("xx", StringComparison.Ordinal) && (statusClass is null || c.Key.EndsWith(statusClass, StringComparison.Ordinal)))
|
||||
.Sum(c => c.Value);
|
||||
|
||||
async Task ReloadEvents()
|
||||
{
|
||||
events = [];
|
||||
hasMoreEvents = false;
|
||||
await LoadEvents();
|
||||
}
|
||||
|
||||
async Task LoadEvents()
|
||||
{
|
||||
isLoadingMore = true;
|
||||
var page = await AdminService.Events(eventsHost?.Trim(), eventsChannel, eventsOutcome, null, events.LastOrDefault()?.At, EventsPageSize);
|
||||
isLoadingMore = false;
|
||||
events.AddRange(page);
|
||||
hasMoreEvents = page.Count == EventsPageSize;
|
||||
}
|
||||
|
||||
async Task MoreEvents() => await LoadEvents();
|
||||
|
||||
async Task ChangeChannel(string value)
|
||||
{
|
||||
eventsChannel = value;
|
||||
await ReloadEvents();
|
||||
}
|
||||
|
||||
async Task ChangeOutcome(string value)
|
||||
{
|
||||
eventsOutcome = value;
|
||||
await ReloadEvents();
|
||||
}
|
||||
|
||||
static string Ms(int? value) => value?.ToString() ?? "—";
|
||||
@@ -191,7 +351,7 @@
|
||||
{
|
||||
days = value;
|
||||
page = 1;
|
||||
await LoadData();
|
||||
await LoadDays();
|
||||
}
|
||||
|
||||
async Task ChangeSort(string value)
|
||||
|
||||
Reference in new issue
Block a user