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:
thepraandClaude Opus 5.5 committed 2026-10-05 06:20:18 +02:00
1 parent 03f4f2ad53
commit d7d836ba39
40 files changed
+3155 -62

No files matched your search

+18
View File
@@ -18,10 +18,19 @@ public static class APIs
public const string GET_SniffAgain = "clientapi/user/sniff/again";
public const string GET_CurrentVersion = "clientapi/data/current-version";
public const string GET_Personas = "clientapi/avatar/private/list";
public const string POST_InsertPersona = "clientapi/avatar/private/insert";
public const string GET_Groups = "clientapi/group/list";
public const string GET_Posts = "clientapi/post/list";
public const string GET_Nearby = "clientapi/post/nearby";
public const string POST_InsertPost = "clientapi/post/insert";
public const string GET_ModeratorReports = "clientapi/moderator/reports";
public static string POST_M_ResolveReport(string reportId) => $"clientapi/moderator/reports/{Uri.EscapeDataString(reportId)}/resolve";
public const string GET_AdminDomainBlocks = "clientapi/admin/domainblocks/list";
public const string POST_AdminDomainBlock = "clientapi/admin/domainblocks/insert";
public static string POST_M_AdminDomainUnblock(string domain) => $"clientapi/admin/domainblocks/delete?domain={Uri.EscapeDataString(domain)}";
public const string GET_StatisticsOverview = "clientapi/admin/statistics/overview";
public const string GET_StatisticsHosts = "clientapi/admin/statistics/hosts";
public const string GET_StatisticsCrawler = "clientapi/admin/statistics/crawler";
}
public static class OAuth
@@ -36,6 +45,12 @@ public static class APIs
public static class Mastodon
{
public const string GET_VerifyCredentials = "api/v1/accounts/verify_credentials";
public const string PATCH_UpdateCredentials = "api/v1/accounts/update_credentials";
public const string GET_Mutes = "api/v1/mutes";
public const string GET_Blocks = "api/v1/blocks";
public const string GET_DomainBlocks = "api/v1/domain_blocks";
public const string POST_DomainBlocks = "api/v1/domain_blocks";
public const string DELETE_DomainBlocks = "api/v1/domain_blocks";
public const string GET_HomeTimeline = "api/v1/timelines/home";
public const string GET_PublicTimeline = "api/v1/timelines/public";
public const string GET_Statuses = "api/v1/statuses";
@@ -43,6 +58,8 @@ public static class APIs
public const string GET_Favourites = "api/v1/favourites";
public const string GET_Bookmarks = "api/v1/bookmarks";
public const string GET_Conversations = "api/v1/conversations";
public static string POST_M_ReadConversation(string conversationId) => $"api/v1/conversations/{Uri.EscapeDataString(conversationId)}/read";
public static string DELETE_M_Conversation(string conversationId) => $"api/v1/conversations/{Uri.EscapeDataString(conversationId)}";
public const string GET_Notifications = "api/v1/notifications";
public const string POST_Media = "api/v2/media";
public const string GET_AccountLookup = "api/v1/accounts/lookup";
@@ -53,6 +70,7 @@ public static class APIs
public static string GET_M_TagTimeline(string tag) => $"api/v1/timelines/tag/{Uri.EscapeDataString(tag)}";
public static string GET_M_Account(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}";
public static string GET_M_AccountStatuses(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}/statuses";
public static string GET_M_AccountFollowing(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}/following";
public static string GET_M_Status(string statusId) => $"api/v1/statuses/{Uri.EscapeDataString(statusId)}";
public static string GET_M_Context(string statusId) => $"api/v1/statuses/{Uri.EscapeDataString(statusId)}/context";
public static string DELETE_M_Status(string statusId) => $"api/v1/statuses/{Uri.EscapeDataString(statusId)}";
+31
View File
@@ -25,6 +25,13 @@ public class Account
public string LastStatusAt { get; set; }
public List<CustomEmoji> Emojis { get; set; } = [];
public List<AccountField> Fields { get; set; } = [];
/// <summary>Whether it is listed in the directory and suggested; null when its server does not say.</summary>
public bool? Discoverable { get; set; }
/// <summary>Whether its public posts may be found by full-text search.</summary>
public bool? Indexable { get; set; }
/// <summary>The persona's own account only (verify_credentials, update_credentials): its profile as written and its
/// posting defaults.</summary>
public AccountSource Source { get; set; }
/// <summary>The account's server: the host of its ActivityPub id.</summary>
public string Host => System.Uri.TryCreate(Uri, UriKind.Absolute, out var uri) ? uri.Host.ToLowerInvariant() : default;
@@ -33,6 +40,27 @@ public class Account
public string Name => string.IsNullOrWhiteSpace(DisplayName) ? Username : DisplayName;
}
public class AccountSource
{
/// <summary>The biography as written, before PrivaPub renders it.</summary>
public string Note { get; set; }
public List<AccountField> Fields { get; set; } = [];
/// <summary>The default visibility of a new post: public, unlisted or private.</summary>
public string Privacy { get; set; }
public bool Sensitive { get; set; }
public string Language { get; set; }
/// <summary>Who may quote the persona's posts: public, followers or nobody.</summary>
public string QuotePolicy { get; set; }
public int FollowRequestsCount { get; set; }
}
/// <summary>A page of accounts (mutes, blocks), and the cursor of the next one: null at the end.</summary>
public class AccountPage
{
public List<Account> Accounts { get; set; } = [];
public string MaxId { get; set; }
}
public class AccountField
{
public string Name { get; set; }
@@ -55,6 +83,9 @@ public class Relationship
public bool Blocking { get; set; }
public bool BlockedBy { get; set; }
public bool Muting { get; set; }
public bool MutingNotifications { get; set; }
public bool ShowingReblogs { get; set; }
public bool Notifying { get; set; }
public bool Requested { get; set; }
public bool RequestedBy { get; set; }
public bool DomainBlocking { get; set; }
+2
View File
@@ -5,6 +5,8 @@ public class PrivaPubStatus
{
/// <summary>The ActivityPub type of a remote object: Note, Article, Page, Video, Audio, Event, Question…</summary>
public string ObjectType { get; set; }
/// <summary>Its community's moderators locked it: PrivaPub refuses a reply.</summary>
public bool Locked { get; set; }
public string Title { get; set; }
public string Excerpt { get; set; }
public string Cover { get; set; }
+101
View File
@@ -0,0 +1,101 @@
using decePubClient.Models.Mastodon;
using decePubClient.Models.Types;
namespace decePubClient.Models
{
/// <summary>
/// The persona's profile as Settings edits it, which is what update_credentials takes: the words as written (its
/// account's Source), the flags, the posting defaults, and a new avatar or header when one was picked. Fields always
/// holds FieldCount rows; a row without a name is dropped.
/// </summary>
public class ProfileForm
{
public const int FieldCount = 4;
public const int DisplayNameLength = 30;
public const int NoteLength = 500;
public const int FieldLength = 255;
public string DisplayName { get; set; }
public string Note { get; set; }
public bool Locked { get; set; }
public bool Bot { get; set; }
public bool Discoverable { get; set; }
public bool Indexable { get; set; }
public MessageType Privacy { get; set; } = MessageType.Public;
public bool Sensitive { get; set; }
public string Language { get; set; }
public QuotePolicy QuotePolicy { get; set; } = QuotePolicy.Public;
public List<AccountField> Fields { get; set; } = [];
public UploadMedia Avatar { get; set; }
public UploadMedia Header { get; set; }
public static ProfileForm Of(Account account)
{
var source = account.Source ?? new();
var fields = source.Fields.Count > 0 ? source.Fields : account.Fields;
return new()
{
DisplayName = account.DisplayName,
Note = source.Note,
Locked = account.Locked,
Bot = account.Bot,
Discoverable = account.Discoverable == true,
Indexable = account.Indexable == true,
Privacy = source.Privacy switch
{
"private" => MessageType.FollowersOnly,
"unlisted" => MessageType.Unlisted,
_ => MessageType.Public
},
Sensitive = source.Sensitive,
Language = source.Language,
QuotePolicy = source.QuotePolicy switch
{
"followers" => QuotePolicy.Followers,
"nobody" => QuotePolicy.Nobody,
_ => QuotePolicy.Public
},
Fields = [.. fields.Take(FieldCount).Select(f => new AccountField { Name = f.Name, Value = f.Value }),
.. Enumerable.Range(0, Math.Max(0, FieldCount - fields.Count)).Select(_ => new AccountField())]
};
}
/// <summary>The form as update_credentials reads it, with the pictures as files.</summary>
public MultipartFormDataContent Content()
{
var content = new MultipartFormDataContent
{
{ new StringContent(DisplayName?.Trim() ?? ""), "display_name" },
{ new StringContent(Note ?? ""), "note" },
{ new StringContent(Flag(Locked)), "locked" },
{ new StringContent(Flag(Bot)), "bot" },
{ new StringContent(Flag(Discoverable)), "discoverable" },
{ new StringContent(Flag(Indexable)), "indexable" },
{ new StringContent(Privacy switch { MessageType.FollowersOnly => "private", MessageType.Unlisted => "unlisted", _ => "public" }), "source[privacy]" },
{ new StringContent(Flag(Sensitive)), "source[sensitive]" },
{ new StringContent(Language ?? ""), "source[language]" },
{ new StringContent(QuotePolicy switch { QuotePolicy.Followers => "followers", QuotePolicy.Nobody => "nobody", _ => "public" }), "source[quote_policy]" }
};
// every row is sent, so a row emptied here is removed there
for (var i = 0; i < Fields.Count; i++)
{
content.Add(new StringContent(Fields[i].Name?.Trim() ?? ""), $"fields_attributes[{i}][name]");
content.Add(new StringContent(Fields[i].Value?.Trim() ?? ""), $"fields_attributes[{i}][value]");
}
if (Avatar is not null)
content.Add(Picture(Avatar), "avatar", Avatar.FileName);
if (Header is not null)
content.Add(Picture(Header), "header", Header.FileName);
return content;
}
static string Flag(bool value) => value ? "true" : "false";
static ByteArrayContent Picture(UploadMedia media)
{
var picture = new ByteArrayContent(media.Blob);
picture.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(media.ContentType);
return picture;
}
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace decePubClient.Models.Types
{
/// <summary>Who may quote a persona's posts (Mastodon's quote_policy).</summary>
public enum QuotePolicy
{
Public = 1,
Followers,
Nobody
}
}