Filters: words and posts a persona would rather not see
Mastodon's v2 filters replace the empty stubs: a filter's title, contexts, action (warn, hide, blur) and expiry, its keywords (whole words or not, taken as JSON objects, listed or numbered form fields, with id and _destroy on update) and its statuses, each with their own endpoints; the v1 API is the same filters seen keyword by keyword. Every status a persona reads carries the filters it matches in `filtered` (a boost as what it boosts), matched as Mastodon matches: warning, title, text, poll options and media descriptions. Clients apply context and action. Filters never federate, and go with a deleted persona. 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
b710493701
commit
5b3e456e09
12 files changed
+759
-13
No files matched your search
@@ -0,0 +1,50 @@
|
||||
using MongoDB.Entities;
|
||||
|
||||
namespace PrivaPub.Models.Social
|
||||
{
|
||||
//a persona's filter (Mastodon's v2 filters, owner decision 2026-10-04): words and posts it would rather not see, in
|
||||
//some contexts, to be warned about, hidden or blurred. Statuses carry the filters they match (`filtered`) and the client
|
||||
//applies context and action, as Mastodon's do. Filters are the persona's own and never federate.
|
||||
public class PersonaFilter : Entity
|
||||
{
|
||||
public string AvatarId { get; set; }
|
||||
public string Title { get; set; }
|
||||
public List<string> Context { get; set; } = new();
|
||||
public DateTime? ExpiresAt { get; set; }
|
||||
public string Action { get; set; } = FilterActions.Warn;
|
||||
public List<FilterKeyword> Keywords { get; set; } = new();
|
||||
public List<FilterStatus> Statuses { get; set; } = new();
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public bool IsActive(DateTime now) => ExpiresAt == default || ExpiresAt > now;
|
||||
}
|
||||
|
||||
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 PostId { get; set; }
|
||||
}
|
||||
|
||||
public static class FilterActions
|
||||
{
|
||||
public const string Warn = "warn";
|
||||
public const string Hide = "hide";
|
||||
public const string Blur = "blur";
|
||||
|
||||
public static bool IsValid(string value) => value is Warn or Hide or Blur;
|
||||
}
|
||||
|
||||
public static class FilterContexts
|
||||
{
|
||||
public static readonly string[] All = { "home", "notifications", "public", "thread", "account" };
|
||||
|
||||
public static bool IsValid(string value) => All.Contains(value);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user