M4: every delivery attempt is recorded
DeliveryJobHandler records each attempt as an 'out' event: the activity, object type and audience read from the body (ActivityShape, shared with the inbox side), the receiving server, the status, the time the POST took, the wait since it was queued, the bytes, the attempt number and the signer's kind (none for circles or private traffic). The outcome is ok, deferred (429 or 503 with Retry-After, or an open breaker: host-unavailable), retry (5xx, 408, timeout, network), or dead: another 4xx, private-address, not-deliverable, signer-gone, or a retry at the last attempt. Until now none of this outlived the job's seven-day TTL, and the last error was overwritten on success. 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
ac7cbd136b
commit
e247001bdb
4 files changed
+249
-21
No files matched your search
@@ -97,7 +97,7 @@ namespace PrivaPub.Federation.Inbox
|
||||
LatencyMs = (int)Stopwatch.GetElapsedTime(started).TotalMilliseconds,
|
||||
WaitMs = (int)Math.Min(int.MaxValue, Math.Max(0, (DateTime.UtcNow - (payload.ReceivedAt ?? job.CreatedAt)).TotalMilliseconds)),
|
||||
Attempt = job.Attempts,
|
||||
Audience = verdict.Audience ?? Audience(activity),
|
||||
Audience = verdict.Audience ?? ActivityShape.Of(activity).Audience,
|
||||
LocalKind = verdict.LocalKind,
|
||||
AgeSeconds = verdict.AgeSeconds,
|
||||
Inbox = payload.Inbox,
|
||||
@@ -105,24 +105,5 @@ namespace PrivaPub.Federation.Inbox
|
||||
Features = type is "Create" or "Update" && embedded != default ? ObjectFeatures.Detect(embedded) : default
|
||||
}, payload.ActorURI);
|
||||
}
|
||||
|
||||
static string Audience(JsonNode activity)
|
||||
{
|
||||
var source = activity?["to"] != default || activity?["cc"] != default ? activity : activity?["object"] as JsonObject;
|
||||
var to = Addresses(source?["to"]);
|
||||
var cc = Addresses(source?["cc"]);
|
||||
if (to.Any(Addressing.IsPublic))
|
||||
return Interactions.Public;
|
||||
if (cc.Any(Addressing.IsPublic))
|
||||
return Interactions.Unlisted;
|
||||
return to.Count + cc.Count == 0 ? Interactions.None : Interactions.Private;
|
||||
}
|
||||
|
||||
static List<string> Addresses(JsonNode node) => node switch
|
||||
{
|
||||
JsonArray array => array.Select(Id).Where(id => id != default).ToList(),
|
||||
JsonNode single when Id(single) is { } id => new List<string> { id },
|
||||
_ => new List<string>()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user