Filters: made on /filters, applied by each card where it is
The persona's filters (PrivaPub's /api/v2/filters): made, given words and whole-word rules, contexts, an action and an expiry on /filters (linked from Settings), and deleted; posts filtered one by one can be taken out. Every status says which filters it matches; each page tells its cards where they are (home and lists, notifications, public feeds, the thread around the opened post, profiles), and a card leaves its post out (hide), folds it behind the filter's title with a way to show it anyway (warn), or blurs its media (blur). The e2e test folds and then hides a post of the persona's own. 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
e2491de16e
commit
9a752d9288
18 files changed
+1182
-240
No files matched your search
@@ -0,0 +1,80 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace decePubClient.Models.Mastodon;
|
||||
|
||||
/// <summary>A persona's filter (Mastodon's v2 filters): words and posts it would rather not see in some contexts, to be
|
||||
/// warned about, hidden or blurred. Statuses carry the filters they match (Status.Filtered); the client applies the
|
||||
/// context and the action.</summary>
|
||||
public class Filter
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public List<FilterContext> Context { get; set; } = [];
|
||||
public DateTime? ExpiresAt { get; set; }
|
||||
public FilterAction FilterAction { get; set; } = FilterAction.Warn;
|
||||
public List<FilterKeyword> Keywords { get; set; } = [];
|
||||
public List<FilterStatus> Statuses { get; set; } = [];
|
||||
|
||||
public bool IsActive => ExpiresAt is null || ExpiresAt > DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public class FilterKeyword
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Keyword { get; set; }
|
||||
public bool WholeWord { get; set; }
|
||||
}
|
||||
|
||||
public class FilterStatus
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string StatusId { get; set; }
|
||||
}
|
||||
|
||||
public class FilterResult
|
||||
{
|
||||
public Filter Filter { get; set; }
|
||||
public List<string> KeywordMatches { get; set; } = [];
|
||||
public List<string> StatusMatches { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>Where a filter applies; a card is told which of these it is shown in.</summary>
|
||||
[JsonConverter(typeof(JsonStringEnumConverter<FilterContext>))]
|
||||
public enum FilterContext
|
||||
{
|
||||
[JsonStringEnumMemberName("home")] Home,
|
||||
[JsonStringEnumMemberName("notifications")] Notifications,
|
||||
[JsonStringEnumMemberName("public")] Public,
|
||||
[JsonStringEnumMemberName("thread")] Thread,
|
||||
[JsonStringEnumMemberName("account")] Account
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(JsonStringEnumConverter<FilterAction>))]
|
||||
public enum FilterAction
|
||||
{
|
||||
/// <summary>The post is folded behind the filter's title.</summary>
|
||||
[JsonStringEnumMemberName("warn")] Warn,
|
||||
/// <summary>The post is not shown at all.</summary>
|
||||
[JsonStringEnumMemberName("hide")] Hide,
|
||||
/// <summary>The post's media are blurred, as sensitive media are.</summary>
|
||||
[JsonStringEnumMemberName("blur")] Blur
|
||||
}
|
||||
|
||||
/// <summary>What making or changing a filter sends; ExpiresIn 0 means never.</summary>
|
||||
public class FilterForm
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public List<FilterContext> Context { get; set; } = [];
|
||||
public FilterAction FilterAction { get; set; } = FilterAction.Warn;
|
||||
public int? ExpiresIn { get; set; }
|
||||
public List<FilterKeywordForm> KeywordsAttributes { get; set; } = [];
|
||||
}
|
||||
|
||||
public class FilterKeywordForm
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Keyword { get; set; }
|
||||
public bool WholeWord { get; set; }
|
||||
[JsonPropertyName("_destroy")]
|
||||
public bool? Destroy { get; set; }
|
||||
}
|
||||
@@ -42,6 +42,8 @@ public class Status
|
||||
public Quote Quote { get; set; }
|
||||
/// <summary>Emoji reactions (PrivaPub sends Pleroma's and Misskey's forms as one list).</summary>
|
||||
public List<EmojiReaction> EmojiReactions { get; set; } = [];
|
||||
/// <summary>The persona's filters this post matches, whatever their context (the card picks those of where it is).</summary>
|
||||
public List<FilterResult> Filtered { get; set; } = [];
|
||||
public int QuotesCount { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user