House rules: primary constructors, a cancellation token on every async call, and the rules fail the build
Build / Build (push) Successful in 30s

- Services, controllers and jobs take their dependencies through primary
  constructors and use them directly; where a method already named a local
  after a dependency, the dependency takes its type's name.
- Every async method takes a CancellationToken last and passes it down to
  MongoDB, HTTP and the job queue. The setup claim is still given back when
  a request is cancelled.
- The federation and media options are read through IOptionsMonitor.
- The Mastodon entities keep sending "" for empty strings, and every model
  field where null means something says so.
- The inbox's 503 with Retry-After, which other servers retry, is the one
  server error left, and says why.
- Arasaka.HouseRules.Analyzers checks all of this in every build, here and in
  PrivaPub.ClientModels as decePubClient builds it.

Checked against GoToSocial in the pasture: 64 passed, 0 failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-11-10 01:24:43 +01:00
1 parent f0a14c737f
commit 0f73f69239
176 files changed
+2789 -3974

No files matched your search

@@ -30,7 +30,9 @@ namespace PrivaPub.Models.Federation
public DateTime? Published { get; set; }
public DateTime? Updated { get; set; }
public List<ObjectRevision> Revisions { get; set; } = new();
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null on records older than v1.16, which are read again from the raw form; an empty list would mean none.")]
public List<string> Extensions { get; set; }//ObjectFeatures, stored for statistics; null on records older than v1.16
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null on records older than v1.16, which are read again from the raw form; an empty list would mean none.")]
public List<string> ContextNamespaces { get; set; }
}
+2
View File
@@ -42,6 +42,7 @@ namespace PrivaPub.Models.Jobs
public string InstanceApi { get; set; }//"mastodon-v2" or "mastodon-v1"
public string InstanceApiRaw { get; set; }//admin only: it names maintainers and contact accounts
public string Title { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null when the server does not report its languages, which is not the same as none.")]
public List<string> Languages { get; set; }
public string RegistrationMode { get; set; }//open, approval, closed
public int? MaxPostChars { get; set; }
@@ -82,6 +83,7 @@ namespace PrivaPub.Models.Jobs
public long? LocalPosts { get; set; }
public bool? OpenRegistrations { get; set; }
public string RegistrationMode { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null when the server does not report its languages, which is not the same as none.")]
public List<string> Languages { get; set; }
public string Country { get; set; }
public string City { get; set; }
+1
View File
@@ -15,6 +15,7 @@ namespace PrivaPub.Models.Media
public string Blurhash { get; set; }
public int? Width { get; set; }
public int? Height { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null when no focal point was set, and the image is centred.")]
public float[] Focus { get; set; }
public double? DurationSeconds { get; set; }
// audio and video sent to /api/v2/media are processed by a job: "pending" until then, "failed" (with why) if it can't be
+2 -1
View File
@@ -47,8 +47,9 @@ namespace PrivaPub.Models.Post
[BsonIgnoreIfNull]
public PostPoll Poll { get; set; }
[BsonIgnoreIfNull]
public List<PostFlair> Flairs { get; set; }
public List<PostFlair> Flairs { get; set; } = [];
[BsonIgnoreIfNull]
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null when the post does not state searchableBy (FEP-268d); an empty list would mean nobody may search it.")]
public List<string> SearchableBy { get; set; }//FEP-268d on the post itself: outranks its author's
public List<float> Location { get; set; } = new();
public float RangeKm { get; set; } = 5.0f;
+1
View File
@@ -16,6 +16,7 @@ namespace PrivaPub.Models.Post
public string Blurhash { get; set; }
public int? Width { get; set; }
public int? Height { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null when no focal point was set, and the image is centred.")]
public float[] Focus { get; set; }
public string RemotePreviewURL { get; set; }//the remote thumbnail (attachment icon), served through the proxy
public double? DurationSeconds { get; set; }
+1 -1
View File
@@ -37,7 +37,7 @@ namespace PrivaPub.Models
DB.Default.Update<ServerSetup>().Match(s => s.ID == Name && s.AdminId == null).Modify(s => s.AdminId, adminId).ExecuteAsync(token);
/// <summary>Gives a claim back when its login couldn't be made; a named administrator is never given back.</summary>
public static Task Release() =>
public static Task Release(CancellationToken token = default) =>
DB.Default.DeleteAsync<ServerSetup>(s => s.ID == Name && s.AdminId == null);//a delete takes no token outside a transaction
/// <summary>Closes setup for an administrator made elsewhere (the CLI, a server that had one already).</summary>
+1
View File
@@ -14,6 +14,7 @@ namespace PrivaPub.Models.Social
public string FollowActivityURI { get; set; }
public bool ShowReblogs { get; set; } = true;
public bool Notify { get; set; }//Mastodon's notify (R8): a `status` notification for each new post of the account
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null follows every language, as on Mastodon; an empty list would follow none.")]
public List<string> Languages { get; set; }//Mastodon's languages (R8): only its posts in these reach the home; null, every language
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public int Resent { get; set; }//how many times a request still unanswered was sent again (FollowService.ResendPending)
+1
View File
@@ -16,6 +16,7 @@ namespace PrivaPub.Models.Social
[MongoDB.Bson.Serialization.Attributes.BsonIgnoreIfNull]
public string WarningAction { get; set; }//a warning from this server's staff: Mastodon's AccountWarning action (silence, suspend, delete_statuses)
[MongoDB.Bson.Serialization.Attributes.BsonIgnoreIfNull]
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null when the warning is about PostId alone, and the mapper falls back to it.")]
public List<string> StatusIds { get; set; }//the posts a warning is about, when more than PostId
public bool IsRead { get; set; }
public bool Filtered { get; set; }//held back by the persona's notification policy, in a NotificationRequest
@@ -26,6 +26,7 @@ namespace PrivaPub.Models.Statistics
public string Inbox { get; set; }//shared | personal
public string Signature { get; set; }//"cavage:rsa-sha256", "none"
public string ActorHash { get; set; }//keyed with that day's salt, never reversible, never linkable across days
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Statistics store null rather than an empty list when the activity uses no extension.")]
public List<string> Features { get; set; }
public long? AgeSeconds { get; set; }//Update and Delete: how old the object was
public bool Crawl { get; set; }
+2
View File
@@ -68,6 +68,7 @@ namespace PrivaPub.Models.User
public string PictureDescription { get; set; }
public string HeaderDescription { get; set; }
public DateTime? Published { get; set; }//the actor's own published
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Statistics store null rather than an empty list when the document uses no extension.")]
public List<string> Features { get; set; }//protocol extensions its document uses, for statistics (ActorFeatures)
public string ActorURI { get; set; }//id
@@ -81,6 +82,7 @@ namespace PrivaPub.Models.User
public string FeaturedTagsURL { get; set; }//featuredTags: the hashtags it features (R8)
public List<PrivaPub.Models.Post.PostFlair> Flairs { get; set; } = new();//a community's labels for its posts
public List<string> FeedCommunities { get; set; } = new();//a feed's communities, its `following` (Lemmy's multi-communities, PieFed's feeds)
[System.Diagnostics.CodeAnalysis.SuppressMessage("HouseRules", "HR0006", Justification = "Null when the account does not state searchableBy (FEP-268d); an empty list would mean nobody may search it.")]
public List<string> SearchableBy { get; set; }//FEP-268d, when the account states it: outranks IsIndexable
public string ModeratorsURL { get; set; }//a community's attributedTo (Lemmy, PieFed, Mbin): the collection of its moderators
public List<AssertionKey> AssertionKeys { get; set; } = new();//its Ed25519 keys (FEP-521a), which prove what it sends (FEP-8b32)