Settings, Administration and conversations; threads that fill in
Settings, which held only the theme, now belong to the persona too: - its profile (update_credentials, a new PATCH in IHttpService): pictures, name, biography and fields as written, locked, bot, discoverable, indexable, and how its posts start (visibility, language, sensitive media, who may quote them); the composer starts at that visibility; - the root's personas, each used in turn, and a new one made; - the accounts it muted or blocked and the servers it blocked, each undone there, a server blocked from a pasted address or handle; - its follows, lists, blocks, mutes, blocked servers and bookmarks exported and imported as the CSV files Mastodon writes (PortabilityService): an import resolves each row through PrivaPub, one at a time, and can stop. Administration opens to moderators: reports, resolved there; and for administrators the servers blocked for everyone and the federation statistics (traffic by server, delivery success and latency, the crawler). The Direct tab pages conversations, badges the unread ones, and a card marks one read or takes it off the list; opening one reads it. A remote thread is read again 4 and 15 seconds after it opens, since PrivaPub then fetches the replies its servers hold. A thread its community locked shows a lock instead of a reply button, reactions stay visible below a content warning, and a searched handle opens its account's profile whatever else matched. The e2e tests cover each: the profile saved and read back, a persona made, servers blocked and imported, follows exported, an instance block and the statistics as the pasture's admin, a conversation read and removed, and a reply only Mastodon held appearing in its thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
03f4f2ad53
commit
d7d836ba39
40 files changed
+3155
-62
No files matched your search
@@ -1,7 +1,11 @@
|
||||
@page "/administration"
|
||||
@attribute [Authorize(Policy = Policies.IsModerator)]
|
||||
@inherits LocalizableComponentBase
|
||||
|
||||
<Title>@Localizer["Settings"]</Title>
|
||||
<Title>@Localizer["Administration"]</Title>
|
||||
|
||||
@* Moderators handle reports; administrators also block servers for everyone and read the federation statistics. The
|
||||
other sections wait for PrivaPub endpoints that do not exist yet. *@
|
||||
|
||||
<section class="block relative w-full h-full neo-inset neo-xs rounded-xl">
|
||||
|
||||
@@ -25,18 +29,44 @@
|
||||
<DCollapse Icon="DCollapseIcon.Arrow">
|
||||
<Header>
|
||||
<p class="inline-flex items-center gap-2">
|
||||
<i class="ion-md-albums text-xl"></i> <span>@Localizer["Reports"]</span>
|
||||
<i class="ion-md-flag text-xl"></i> <span>@Localizer["Reports"]</span>
|
||||
</p>
|
||||
</Header>
|
||||
<ChildContent>
|
||||
<div class="block w-full p-3 md:p-4">
|
||||
<p class="w-full text-center text-lg">
|
||||
<i class="ion-ios-remove-circle-outline"></i> @Localizer["Empty"]
|
||||
</p>
|
||||
<ReportsPanel />
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
|
||||
<AuthorizeView Policy="@Policies.IsAdmin">
|
||||
<DCollapse Icon="DCollapseIcon.Arrow">
|
||||
<Header>
|
||||
<p class="inline-flex items-center gap-2">
|
||||
<i class="ion-md-globe text-xl"></i> <span>@Localizer["Blocked servers"]</span>
|
||||
</p>
|
||||
</Header>
|
||||
<ChildContent>
|
||||
<div class="block w-full p-3 md:p-4">
|
||||
<ServerBlocksPanel />
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
|
||||
<DCollapse Icon="DCollapseIcon.Arrow">
|
||||
<Header>
|
||||
<p class="inline-flex items-center gap-2">
|
||||
<i class="ion-md-stats text-xl"></i> <span>@Localizer["Statistics"]</span>
|
||||
</p>
|
||||
</Header>
|
||||
<ChildContent>
|
||||
<div class="block w-full p-3 md:p-4">
|
||||
<StatisticsPanel />
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
</AuthorizeView>
|
||||
|
||||
<DCollapse Icon="DCollapseIcon.Arrow">
|
||||
<Header>
|
||||
<p class="inline-flex items-center gap-2">
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
@* A post with its thread (/api/v1/statuses/{id}/context): the posts it answers above, the post, the answers below.
|
||||
The cards do their own actions; a reply or a deletion updates the thread here. The persona's thread filters apply
|
||||
to the posts around the one it opened, never to that one. *@
|
||||
to the posts around the one it opened, never to that one. Opening a remote thread makes PrivaPub read its replies
|
||||
from their servers, so the thread is read twice more, a few seconds later, and what was found joins it. *@
|
||||
<section class="block relative w-full h-full neo-inset neo-xs rounded-xl">
|
||||
<div class="flex flex-col gap-4 p-4 md:p-5 w-full h-full absolute overflow-y-auto">
|
||||
|
||||
@@ -54,10 +55,14 @@
|
||||
|
||||
[Parameter] public string StatusId { get; set; }
|
||||
|
||||
// when the thread is read again, after PrivaPub has had time to fetch the replies held on other servers
|
||||
static readonly TimeSpan[] Rereads = [TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(15)];
|
||||
|
||||
FeedPost current;
|
||||
List<FeedPost> ancestors = [];
|
||||
List<FeedPost> descendants = [];
|
||||
string loadedId;
|
||||
CancellationTokenSource rereading;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
@@ -78,6 +83,9 @@
|
||||
|
||||
async Task LoadData()
|
||||
{
|
||||
rereading?.Cancel();
|
||||
rereading?.Dispose();
|
||||
rereading = null;
|
||||
IsLoading = true;
|
||||
var status = await StatusService.Get(StatusId);
|
||||
if (status is null)
|
||||
@@ -96,6 +104,42 @@
|
||||
var all = ancestors.Append(current).Concat(descendants).ToList();
|
||||
await InstanceService.Resolve(all.Select(p => p.Host).Append(InstanceService.SelfHost));
|
||||
InstanceService.Locate(all);
|
||||
|
||||
if (new[] { current, ancestors.FirstOrDefault() }.Any(p => p is not null && p.Host != InstanceService.SelfHost))
|
||||
{
|
||||
rereading = new();
|
||||
_ = Reread(status.Id, rereading.Token);
|
||||
}
|
||||
}
|
||||
|
||||
// the answers PrivaPub found since, in the thread's order; the cards already shown stay as they are, and one the
|
||||
// thread no longer lists (a reply just made, not yet in it) stays at the end
|
||||
async Task Reread(string statusId, CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var pause in Rereads)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(pause, cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var context = await StatusService.Context(statusId, cancellationToken);
|
||||
if (cancellationToken.IsCancellationRequested || context is null)
|
||||
return;
|
||||
var shown = descendants.ToDictionary(p => p.Key);
|
||||
var found = context.Descendants.Where(s => !shown.ContainsKey(s.Id)).Select(FeedPost.Of).ToList();
|
||||
if (found.Count == 0)
|
||||
continue;
|
||||
var listed = context.Descendants.Select(s => s.Id).ToHashSet();
|
||||
descendants = [.. context.Descendants.Select(s => shown.GetValueOrDefault(s.Id) ?? found.First(p => p.Key == s.Id)),
|
||||
.. descendants.Where(p => !listed.Contains(p.Key))];
|
||||
await InstanceService.Resolve(found.Select(p => p.Host));
|
||||
InstanceService.Locate(found);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void Remove(FeedPost post)
|
||||
@@ -128,4 +172,14 @@
|
||||
}
|
||||
|
||||
async Task Back() => await JS.InvokeVoidAsync("history.back");
|
||||
|
||||
public override async ValueTask DisposeAsync()
|
||||
{
|
||||
if (rereading is not null)
|
||||
{
|
||||
await rereading.CancelAsync();
|
||||
rereading.Dispose();
|
||||
}
|
||||
await base.DisposeAsync();
|
||||
}
|
||||
}
|
||||
+18
-3
@@ -18,7 +18,7 @@
|
||||
</aside>
|
||||
|
||||
<section class="flex flex-col gap-3 min-h-0 flex-1 lg:h-full">
|
||||
<FeedTabs Filter="Filter" Groups="groups" Lists="lists" UnreadNotifications="unreadNotifications" Stats="FeedStats()" IsComposing="isComposing" OnCompose="() => isComposing = !isComposing"
|
||||
<FeedTabs Filter="Filter" Groups="groups" Lists="lists" UnreadNotifications="unreadNotifications" UnreadConversations="unreadConversations" Stats="FeedStats()" IsComposing="isComposing" OnCompose="() => isComposing = !isComposing"
|
||||
OnChanged="ChangeFeed" />
|
||||
|
||||
<div class="relative flex-1 min-h-0 neo-inset neo-xs rounded-xl">
|
||||
@@ -116,6 +116,7 @@
|
||||
List<ViewGroup> groups = [];
|
||||
List<MastodonList> lists = [];
|
||||
int unreadNotifications;
|
||||
int unreadConversations;
|
||||
string maxId;
|
||||
string minId;
|
||||
string loadError;
|
||||
@@ -299,7 +300,14 @@
|
||||
{
|
||||
while (await pollTimer.WaitForNextTickAsync(cancellationToken))
|
||||
{
|
||||
if (IsLoading || CascadingState.IsOffline || minId is null || Streaming.IsOpen || Filter.TimelineType is TimelineType.Nearby or TimelineType.Direct
|
||||
// no stream tells of direct messages: their tab's badge is counted again on every tick
|
||||
if (!IsLoading && CascadingState.IsOnline && Filter.TimelineType is not TimelineType.Direct
|
||||
&& await TimelineService.UnreadConversations(cancellationToken) is var unread && unread != unreadConversations)
|
||||
{
|
||||
unreadConversations = unread;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
if (IsLoading || CascadingState.IsOffline || minId is null || Streaming.IsOpen || Filter.TimelineType is TimelineType.Nearby
|
||||
|| Filter.TimelineType is TimelineType.Groups && groups.FirstOrDefault(g => g.Id == Filter.GroupId)?.IsCommunity != true
|
||||
|| !await feedModule.InvokeAsync<bool>("isVisible", cancellationToken))
|
||||
continue;
|
||||
@@ -311,9 +319,15 @@
|
||||
continue;
|
||||
|
||||
var known = posts.Concat(pending).Select(p => p.Key).ToHashSet();
|
||||
var newer = ((FeedPage)result.Data).Posts.Where(p => known.Add(p.Key)).ToList();
|
||||
var page = ((FeedPage)result.Data).Posts;
|
||||
// a conversation with a newer message is the same item, moved up with its new message
|
||||
var newer = Filter.TimelineType is TimelineType.Direct
|
||||
? page.Where(p => posts.Concat(pending).All(shown => shown.Key != p.Key || shown.CursorId != p.CursorId)).ToList()
|
||||
: page.Where(p => known.Add(p.Key)).ToList();
|
||||
if (newer.Count == 0)
|
||||
continue;
|
||||
posts.RemoveAll(p => newer.Any(n => n.Key == p.Key));
|
||||
pending.RemoveAll(p => newer.Any(n => n.Key == p.Key));
|
||||
|
||||
pending.InsertRange(0, newer);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
@@ -335,6 +349,7 @@
|
||||
/// counts what is unread.</summary>
|
||||
async Task ReadNotifications(CancellationToken cancellationToken)
|
||||
{
|
||||
unreadConversations = await TimelineService.UnreadConversations(cancellationToken);
|
||||
if (Filter.TimelineType is not TimelineType.Notifications)
|
||||
{
|
||||
unreadNotifications = await TimelineService.UnreadNotifications(cancellationToken);
|
||||
|
||||
+6
-1
@@ -112,7 +112,12 @@
|
||||
isSearching = false;
|
||||
await InstanceService.Resolve(statuses.Select(p => p.Host).Append(InstanceService.SelfHost));
|
||||
InstanceService.Locate(statuses);
|
||||
if (results.Accounts.Count == 1 && results.Statuses.Count == 0 && form.Query.Contains('@'))
|
||||
// a handle opens its account's profile, whatever else matched
|
||||
var handle = form.Query.Trim().TrimStart('@');
|
||||
if (form.Query.Contains('@') && results.Accounts.FirstOrDefault(a => string.Equals(a.Acct, handle, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals($"{a.Acct}@{InstanceService.SelfHost}", handle, StringComparison.OrdinalIgnoreCase)) is { } exact)
|
||||
Navigation.NavigateTo($"account/{Uri.EscapeDataString(exact.Id)}");
|
||||
else if (results.Accounts.Count == 1 && results.Statuses.Count == 0 && form.Query.Contains('@'))
|
||||
Navigation.NavigateTo($"account/{Uri.EscapeDataString(results.Accounts[0].Id)}");
|
||||
}
|
||||
|
||||
|
||||
+44
-9
@@ -60,6 +60,26 @@
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
|
||||
<DCollapse Icon="DCollapseIcon.Arrow">
|
||||
<Header>
|
||||
<p class="inline-flex items-center gap-2">
|
||||
<i class="ion-md-people text-xl"></i> <span>@Localizer["Personas"]</span>
|
||||
</p>
|
||||
</Header>
|
||||
<ChildContent>
|
||||
<div class="block w-full p-3 md:p-4">
|
||||
@if (CascadingState.IsSignedIn)
|
||||
{
|
||||
<PersonasEditor />
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="link" href="login">@Localizer["Sign in to PrivaPub"]</a>
|
||||
}
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
|
||||
<DCollapse Icon="DCollapseIcon.Arrow">
|
||||
<Header>
|
||||
<p class="inline-flex items-center gap-2">
|
||||
@@ -68,9 +88,14 @@
|
||||
</Header>
|
||||
<ChildContent>
|
||||
<div class="block w-full p-3 md:p-4">
|
||||
<p class="w-full text-center text-lg">
|
||||
<i class="ion-ios-remove-circle-outline"></i> @Localizer["Empty"]
|
||||
</p>
|
||||
@if (CascadingState.IsSignedIn)
|
||||
{
|
||||
<ProfileEditor />
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="link" href="login">@Localizer["Sign in to PrivaPub"]</a>
|
||||
}
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
@@ -83,9 +108,14 @@
|
||||
</Header>
|
||||
<ChildContent>
|
||||
<div class="block w-full p-3 md:p-4">
|
||||
<p class="w-full text-center text-lg">
|
||||
<i class="ion-ios-remove-circle-outline"></i> @Localizer["Empty"]
|
||||
</p>
|
||||
@if (CascadingState.IsSignedIn)
|
||||
{
|
||||
<DataTransfer />
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="link" href="login">@Localizer["Sign in to PrivaPub"]</a>
|
||||
}
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
@@ -98,9 +128,14 @@
|
||||
</Header>
|
||||
<ChildContent>
|
||||
<div class="block w-full p-3 md:p-4">
|
||||
<p class="w-full text-center text-lg">
|
||||
<i class="ion-ios-remove-circle-outline"></i> @Localizer["Empty"]
|
||||
</p>
|
||||
@if (CascadingState.IsSignedIn)
|
||||
{
|
||||
<MutesAndBlocks />
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="link" href="login">@Localizer["Sign in to PrivaPub"]</a>
|
||||
}
|
||||
</div>
|
||||
</ChildContent>
|
||||
</DCollapse>
|
||||
|
||||
Reference in new issue
Block a user