2026-10-05 03:53:51 +02:00
|
|
|
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
|
2026-10-18 08:58:30 +02:00
|
|
|
/// follows it and features it on its profile (both null when nobody is signed in).</summary>
|
2026-10-05 03:53:51 +02:00
|
|
|
public class Tag
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Url { get; set; }
|
|
|
|
|
public List<TagDay> History { get; set; } = [];
|
|
|
|
|
public bool? Following { get; set; }
|
2026-10-18 08:58:30 +02:00
|
|
|
/// <summary>Featured on the persona's profile (Mastodon 4.4's `featuring`).</summary>
|
|
|
|
|
public bool? Featuring { get; set; }
|
2026-10-05 03:53:51 +02:00
|
|
|
|
|
|
|
|
public int WeekUses => History.Sum(h => h.UsesCount);
|
|
|
|
|
public int TodayAccounts => History.FirstOrDefault()?.AccountsCount ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>One day of a tag's or a link's use; Mastodon sends the numbers as strings, the day as unix time.</summary>
|
|
|
|
|
public class TagDay
|
|
|
|
|
{
|
|
|
|
|
public string Day { get; set; }
|
|
|
|
|
public string Uses { get; set; }
|
|
|
|
|
public string Accounts { get; set; }
|
|
|
|
|
|
|
|
|
|
public int UsesCount => int.TryParse(Uses, out var n) ? n : 0;
|
|
|
|
|
public int AccountsCount => int.TryParse(Accounts, out var n) ? n : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>A link many authors shared this week: its preview card with its days.</summary>
|
|
|
|
|
public class TrendLink : PreviewCard
|
|
|
|
|
{
|
|
|
|
|
public List<TagDay> History { get; set; } = [];
|
|
|
|
|
|
|
|
|
|
public int WeekAccounts => History.Sum(h => h.AccountsCount);
|
|
|
|
|
}
|
2026-10-18 08:58:30 +02:00
|
|
|
|
|
|
|
|
/// <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; }
|
|
|
|
|
}
|