R8 the Mastodon API made real in decePub: featured tags, notify, languages, recommendations, notes, suggestions, the direct stream
A profile shows the hashtags an account features as chips opening their feed; under another account's header is what the persona keeps of it for itself alone: for one it follows, a bell (follow with notify), the languages of its posts that reach the home feed (follow with languages[]) and Recommend (endorsements, private here), and for any account a private note saved on blur or with Save. Settings edits the persona's featured hashtags (added by name or from those used lately, 10 at most) and its reading preferences (/clientapi/avatar/private/preferences), which CascadingState keeps per persona and the card applies to sensitive media and content warnings. A hashtag's tab features it on the profile. Explore has Who to follow (/api/v2/suggestions, dismissed for good after asking); Administration has Staff picks. The Direct tab follows the direct stream's conversation events; status notifications show the post. The follows CSV carries notify and languages. Verified: Release build, 0 errors (the 3 warnings were there before). Not run against PrivaPub or in the pasture. 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
566b0e33ea
commit
d33697e3fc
28 files changed
+1784
-52
No files matched your search
@@ -36,6 +36,8 @@ public static class APIs
|
||||
public const string GET_Personas = "clientapi/avatar/private/list";
|
||||
public const string POST_InsertPersona = "clientapi/avatar/private/insert";
|
||||
public const string POST_DeletePersona = "clientapi/avatar/private/delete";
|
||||
public const string GET_PersonaPreferences = "clientapi/avatar/private/preferences";
|
||||
public const string POST_PersonaPreferences = "clientapi/avatar/private/preferences";
|
||||
public const string GET_Groups = "clientapi/group/list";
|
||||
public const string GET_GroupMembers = "clientapi/group/members";
|
||||
public const string POST_InsertGroup = "clientapi/group/insert";
|
||||
@@ -78,6 +80,9 @@ public static class APIs
|
||||
public const string GET_AdminRelays = "clientapi/admin/relays";
|
||||
public const string POST_AdminRelayInsert = "clientapi/admin/relays/insert";
|
||||
public static string POST_M_AdminRelayDelete(string address) => $"clientapi/admin/relays/delete?address={Uri.EscapeDataString(address)}";
|
||||
public const string GET_AdminStaffPicks = "clientapi/admin/staff-picks";
|
||||
public const string POST_AdminStaffPickInsert = "clientapi/admin/staff-picks/insert";
|
||||
public static string POST_M_AdminStaffPickDelete(string accountId) => $"clientapi/admin/staff-picks/delete?accountId={Uri.EscapeDataString(accountId)}";
|
||||
public const string GET_AdminEmojis = "clientapi/admin/emoji/list";
|
||||
public const string POST_AdminEmojiInsert = "clientapi/admin/emoji/insert";
|
||||
public const string POST_AdminEmojiUpdate = "clientapi/admin/emoji/update";
|
||||
@@ -166,6 +171,8 @@ public static class APIs
|
||||
public static string GET_M_AccountFollowing(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}/following";
|
||||
public static string GET_M_AccountFollowers(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}/followers";
|
||||
public static string POST_M_RemoveFromFollowers(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}/remove_from_followers";
|
||||
public static string GET_M_AccountFeaturedTags(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}/featured_tags";
|
||||
public static string POST_M_AccountNote(string accountId) => $"api/v1/accounts/{Uri.EscapeDataString(accountId)}/note";
|
||||
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)}";
|
||||
@@ -199,6 +206,12 @@ public static class APIs
|
||||
public static string POST_M_RevokeQuote(string quotedId, string quotingId) =>
|
||||
$"api/v1/statuses/{Uri.EscapeDataString(quotedId)}/quotes/{Uri.EscapeDataString(quotingId)}/revoke";
|
||||
public const string GET_FollowedTags = "api/v1/followed_tags";
|
||||
public const string GET_FeaturedTags = "api/v1/featured_tags";
|
||||
public const string POST_FeaturedTag = "api/v1/featured_tags";
|
||||
public static string DELETE_M_FeaturedTag(string featuredTagId) => $"api/v1/featured_tags/{Uri.EscapeDataString(featuredTagId)}";
|
||||
public const string GET_FeaturedTagSuggestions = "api/v1/featured_tags/suggestions";
|
||||
public const string GET_Suggestions = "api/v2/suggestions";
|
||||
public static string DELETE_M_Suggestion(string accountId) => $"api/v1/suggestions/{Uri.EscapeDataString(accountId)}";
|
||||
public const string GET_GroupedNotifications = "api/v2/notifications";
|
||||
public const string GET_UnreadNotifications = "api/v2/notifications/unread_count";
|
||||
public static string POST_M_DismissNotificationGroup(string groupKey) => $"api/v2/notifications/{Uri.EscapeDataString(groupKey)}/dismiss";
|
||||
|
||||
@@ -94,10 +94,22 @@ public class Relationship
|
||||
public bool Muting { get; set; }
|
||||
public bool MutingNotifications { get; set; }
|
||||
public bool ShowingReblogs { get; set; }
|
||||
/// <summary>The persona is told of each of the account's new posts (a `status` notification): the follow's notify.</summary>
|
||||
public bool Notifying { get; set; }
|
||||
/// <summary>The languages of its posts that reach the persona's home feed (primary subtags, as PrivaPub keeps them).
|
||||
/// PrivaPub sends null for every language, which the client reads as an empty list does.</summary>
|
||||
public List<string> Languages { get; set; } = [];
|
||||
public bool Requested { get; set; }
|
||||
public bool RequestedBy { get; set; }
|
||||
public bool DomainBlocking { get; set; }
|
||||
/// <summary>In the persona's recommendations (Mastodon's endorsements): private here, listed to the persona alone and
|
||||
/// never federated; only while it follows the account.</summary>
|
||||
public bool Endorsed { get; set; }
|
||||
/// <summary>The persona's own private note on the account (never its login's, never federated); empty for none.</summary>
|
||||
public string Note { get; set; }
|
||||
|
||||
/// <summary>The languages chosen, none meaning every language.</summary>
|
||||
public IReadOnlyList<string> WantedLanguages => Languages ?? [];
|
||||
}
|
||||
|
||||
/// <summary>/api/v2/search: what matched, a remote handle or URL resolved by PrivaPub.</summary>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
namespace decePubClient.Models.Mastodon;
|
||||
|
||||
/// <summary>A hashtag as PrivaPub describes it: its last week of use in public posts it holds, and whether the persona
|
||||
/// follows it (null when nobody is signed in).</summary>
|
||||
/// follows it and features it on its profile (both null when nobody is signed in).</summary>
|
||||
public class Tag
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Url { get; set; }
|
||||
public List<TagDay> History { get; set; } = [];
|
||||
public bool? Following { get; set; }
|
||||
/// <summary>Featured on the persona's profile (Mastodon 4.4's `featuring`).</summary>
|
||||
public bool? Featuring { get; set; }
|
||||
|
||||
public int WeekUses => History.Sum(h => h.UsesCount);
|
||||
public int TodayAccounts => History.FirstOrDefault()?.AccountsCount ?? 0;
|
||||
@@ -31,3 +33,34 @@ public class TrendLink : PreviewCard
|
||||
|
||||
public int WeekAccounts => History.Sum(h => h.AccountsCount);
|
||||
}
|
||||
|
||||
/// <summary>A hashtag an account features on its profile (Mastodon's FeaturedTag): public, so it federates. Mastodon sends
|
||||
/// the count as a string and the last use as a day (yyyy-MM-dd), counted from the account's public and unlisted posts
|
||||
/// PrivaPub holds.</summary>
|
||||
public class FeaturedTag
|
||||
{
|
||||
public string Id { get; set; }
|
||||
/// <summary>The hashtag as the account wrote it (its case kept), without the #.</summary>
|
||||
public string Name { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string StatusesCount { get; set; }
|
||||
public string LastStatusAt { get; set; }
|
||||
|
||||
public int Posts => int.TryParse(StatusesCount, out var n) ? n : 0;
|
||||
|
||||
/// <summary>The day it was last used, or null when never.</summary>
|
||||
public DateTime? LastStatusDay =>
|
||||
DateTime.TryParseExact(LastStatusAt, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var day)
|
||||
? day
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>/api/v2/suggestions: an account to follow and why. Source is staff (picked by the server's staff),
|
||||
/// past_interactions (the persona favourited, boosted or answered it lately) or global (popular here); Sources names the
|
||||
/// reasons (featured, most_followed, most_interactions, past_interactions).</summary>
|
||||
public class Suggestion
|
||||
{
|
||||
public string Source { get; set; }
|
||||
public List<string> Sources { get; set; } = [];
|
||||
public Account Account { get; set; }
|
||||
}
|
||||
@@ -37,6 +37,13 @@ public class InstanceRule
|
||||
public class InstanceConfiguration
|
||||
{
|
||||
public MediaConfiguration MediaAttachments { get; set; } = new();
|
||||
public AccountsConfiguration Accounts { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>What an account may hold: how many hashtags it features on its profile (PrivaPub's 10).</summary>
|
||||
public class AccountsConfiguration
|
||||
{
|
||||
public int MaxFeaturedTags { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>The types an upload may have and how big it may be, as the server enforces them.</summary>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace decePubClient.Models.Types
|
||||
{
|
||||
/// <summary>How the persona's cards show media (Mastodon's reading:expand:media, set through /clientapi): Default hides
|
||||
/// what its author marked sensitive, ShowAll shows everything, HideAll hides every picture, video and sound behind a
|
||||
/// button.</summary>
|
||||
public enum ExpandMedia
|
||||
{
|
||||
Default = 1,
|
||||
ShowAll,
|
||||
HideAll
|
||||
}
|
||||
|
||||
/// <summary>ExpandMedia as PrivaPub names it ("default", "show_all", "hide_all").</summary>
|
||||
public static class ExpandMediaModes
|
||||
{
|
||||
public static ExpandMedia Of(string mode) => mode switch
|
||||
{
|
||||
"show_all" => ExpandMedia.ShowAll,
|
||||
"hide_all" => ExpandMedia.HideAll,
|
||||
_ => ExpandMedia.Default
|
||||
};
|
||||
|
||||
public static string Name(ExpandMedia mode) => mode switch
|
||||
{
|
||||
ExpandMedia.ShowAll => "show_all",
|
||||
ExpandMedia.HideAll => "hide_all",
|
||||
_ => "default"
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user