M3: what each handler did with an activity
Arrival carries a verdict that handlers set with one line before an existing return (Arrival.Drop, Reject, Accept, About), so no handler signature changes. InboxProcessor records it as an 'in' event, with the time taken, the wait since the inbox accepted it, the attempt, the audience (from the post's visibility, or else the activity's addressing), the local actor kind, the object's age for updates, deletes and reactions, and the FEP features of a delivered object. It also records types nothing handles (unknown-type), actors that cannot be loaded (deferred) and handler failures. Drop reasons: fetch-failed, unparseable, misattributed, duplicate, deleted, not-addressed, not-followed, not-public, not-visible, not-deleted, unknown-object, unknown-recipient, cross-origin, unsupported. Accepted sub-reasons: stored, poll-vote, edit, refresh, actor-refresh, actor-delete, removed, tombstone-only, auto-accepted, pending, follow-answer, quote-answer, quote-granted, undone, reaction, reported. Rejected: blocked, ignored, quote-refused. A circle's traffic is private and kindless, and a stranger posting into one is just not-addressed, so the event store cannot reveal a circle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ELjqpznMFMNrJoJUj6K5p2
This commit is contained in:
1 parent
4fa53f63bd
commit
ac7cbd136b
20 files changed
+544
-26
No files matched your search
@@ -1,3 +1,8 @@
|
||||
using PrivaPub.Federation.Actors;
|
||||
using PrivaPub.Infrastructure.Statistics;
|
||||
using PrivaPub.Models.Federation;
|
||||
using PrivaPub.Models.Post;
|
||||
|
||||
namespace PrivaPub.Federation.Inbox
|
||||
{
|
||||
public sealed record Arrival(string ActivityId, string ActivityType, string ActorURI, string Inbox, string KeyId, string Algorithm,
|
||||
@@ -10,5 +15,64 @@ namespace PrivaPub.Federation.Inbox
|
||||
get => current.Value;
|
||||
set => current.Value = value;
|
||||
}
|
||||
|
||||
public ArrivalVerdict Verdict { get; } = new();
|
||||
|
||||
public static void Drop(string reason) => Current?.Verdict.Drop(reason);
|
||||
|
||||
public static void Reject(string reason) => Current?.Verdict.Reject(reason);
|
||||
|
||||
public static void Accept(string reason) => Current?.Verdict.Accept(reason);
|
||||
|
||||
public static void About(string objectType = default, PostVisibility? visibility = default, DateTime? created = default, LocalActor local = default) =>
|
||||
Current?.Verdict.About(objectType, visibility, created, local);
|
||||
}
|
||||
|
||||
public sealed class ArrivalVerdict
|
||||
{
|
||||
public string Outcome { get; private set; }
|
||||
public string Reason { get; private set; }
|
||||
public string ObjectType { get; private set; }
|
||||
public string Audience { get; private set; }
|
||||
public string LocalKind { get; private set; }
|
||||
public long? AgeSeconds { get; private set; }
|
||||
|
||||
public void Drop(string reason) => Decide(Interactions.Dropped, reason);
|
||||
|
||||
public void Reject(string reason) => Decide(Interactions.Rejected, reason);
|
||||
|
||||
public void Accept(string reason) => Decide(Interactions.Accepted, reason);
|
||||
|
||||
void Decide(string outcome, string reason)
|
||||
{
|
||||
if (Outcome != default)
|
||||
return;
|
||||
Outcome = outcome;
|
||||
Reason = reason;
|
||||
}
|
||||
|
||||
public void About(string objectType, PostVisibility? visibility, DateTime? created, LocalActor local)
|
||||
{
|
||||
ObjectType = objectType ?? ObjectType;
|
||||
if (visibility is { } known)
|
||||
Audience = AudienceOf(known);
|
||||
if (created is { } at)
|
||||
AgeSeconds = Math.Max(0, (long)(DateTime.UtcNow - at).TotalSeconds);
|
||||
if (local != default)
|
||||
LocalKind = local.Kind switch
|
||||
{
|
||||
LocalActorKind.Person => "person",
|
||||
LocalActorKind.Group when !local.IsCircle => "group",
|
||||
LocalActorKind.Application => "application",
|
||||
_ => default
|
||||
};
|
||||
}
|
||||
|
||||
public static string AudienceOf(PostVisibility visibility) => visibility switch
|
||||
{
|
||||
PostVisibility.Public => Interactions.Public,
|
||||
PostVisibility.Unlisted => Interactions.Unlisted,
|
||||
_ => Interactions.Private
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user