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
@@ -47,7 +47,7 @@ namespace decePubClient.Services
|
||||
await Statuses(APIs.Mastodon.GET_M_AccountStatuses(groupId), [], maxId, minId, cancellationToken),
|
||||
TimelineType.Groups when query.GroupId is { Length: > 0 } && maxId is null => await Circle(query, cancellationToken),
|
||||
TimelineType.Notifications => await Notifications(maxId, minId, cancellationToken),
|
||||
TimelineType.Direct when maxId is null => await Conversations(cancellationToken),
|
||||
TimelineType.Direct => await Conversations(maxId, minId, cancellationToken),
|
||||
TimelineType.Nearby when maxId is null && query.Latitude is not null && query.Longitude is not null => await Nearby(query, cancellationToken),
|
||||
_ => new WebResult { Data = new FeedPage() }
|
||||
};
|
||||
@@ -119,15 +119,53 @@ namespace decePubClient.Services
|
||||
return new WebResult();
|
||||
}
|
||||
|
||||
/// <summary>Direct conversations, newest first; PrivaPub answers one page.</summary>
|
||||
async Task<WebResult> Conversations(CancellationToken cancellationToken)
|
||||
/// <summary>Direct conversations by their newest message, newest first, paged by that message's id.</summary>
|
||||
async Task<WebResult> Conversations(string maxId, string minId, CancellationToken cancellationToken)
|
||||
{
|
||||
using var response = await httpService.Get(APIs.Mastodon.GET_Conversations, [$"limit={PageSize}"], cancellationToken: cancellationToken);
|
||||
var parameters = new List<string> { $"limit={PageSize}" };
|
||||
if (maxId is not null)
|
||||
parameters.Add($"max_id={Uri.EscapeDataString(maxId)}");
|
||||
if (minId is not null)
|
||||
parameters.Add($"min_id={Uri.EscapeDataString(minId)}");
|
||||
using var response = await httpService.Get(APIs.Mastodon.GET_Conversations, [.. parameters], cancellationToken: cancellationToken);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadWebResult(response.StatusCode, localizer, cancellationToken);
|
||||
|
||||
var conversations = await response.MastodonReadFromJsonAsync<List<Conversation>>(cancellationToken) ?? [];
|
||||
return new WebResult { Data = new FeedPage { Posts = [.. conversations.Where(c => c.LastStatus is not null).Select(FeedPost.Of)] } };
|
||||
var (nextMaxId, nextMinId) = response.PageCursors();
|
||||
return new WebResult
|
||||
{
|
||||
Data = new FeedPage
|
||||
{
|
||||
Posts = [.. conversations.Where(c => c.LastStatus is not null).Select(FeedPost.Of)],
|
||||
MaxId = conversations.Count < PageSize ? null : nextMaxId,
|
||||
MinId = nextMinId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>How many of the newest conversations have a message the persona has not read.</summary>
|
||||
public async Task<int> UnreadConversations(CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var response = await httpService.Get(APIs.Mastodon.GET_Conversations, ["limit=40"], cancellationToken: cancellationToken);
|
||||
return response.IsSuccessStatusCode ? (await response.MastodonReadFromJsonAsync<List<Conversation>>(cancellationToken) ?? []).Count(c => c.Unread) : 0;
|
||||
}
|
||||
|
||||
/// <summary>Marks a conversation read; Data is the conversation.</summary>
|
||||
public async Task<WebResult> ReadConversation(string conversationId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var response = await httpService.Post(APIs.Mastodon.POST_M_ReadConversation(conversationId), cancellationToken: cancellationToken);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return await response.Content.ReadWebResult(response.StatusCode, localizer, cancellationToken);
|
||||
|
||||
return new WebResult { Data = await response.MastodonReadFromJsonAsync<Conversation>(cancellationToken) };
|
||||
}
|
||||
|
||||
/// <summary>Takes a conversation off the list until a newer message; its messages stay.</summary>
|
||||
public async Task<WebResult> RemoveConversation(string conversationId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var response = await httpService.Delete(APIs.Mastodon.DELETE_M_Conversation(conversationId), cancellationToken: cancellationToken);
|
||||
return response.IsSuccessStatusCode ? new WebResult() : await response.Content.ReadWebResult(response.StatusCode, localizer, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>A circle's posts: their ids from /clientapi, the posts from the Mastodon API, newest first.</summary>
|
||||
|
||||
Reference in new issue
Block a user