🐛 Adjusted delivery of actor update

This commit is contained in:
2025-12-31 01:21:47 +08:00
parent cb37edc0bb
commit 71031e2222

View File

@@ -228,7 +228,7 @@ public class ActivityPubDeliveryService(
["id"] = postUrl, ["id"] = postUrl,
["type"] = post.Type == PostType.Article ? "Article" : "Note", ["type"] = post.Type == PostType.Article ? "Article" : "Note",
["published"] = (post.PublishedAt ?? post.CreatedAt).ToDateTimeOffset(), ["published"] = (post.PublishedAt ?? post.CreatedAt).ToDateTimeOffset(),
["updated"] = post.EditedAt?.ToDateTimeOffset(), ["updated"] = post.EditedAt?.ToDateTimeOffset() ?? new DateTimeOffset(),
["attributedTo"] = actorUrl, ["attributedTo"] = actorUrl,
["content"] = post.Content ?? "", ["content"] = post.Content ?? "",
["to"] = new[] { "https://www.w3.org/ns/activitystreams#Public" }, ["to"] = new[] { "https://www.w3.org/ns/activitystreams#Public" },
@@ -312,7 +312,7 @@ public class ActivityPubDeliveryService(
var actorUrl = actor.Uri; var actorUrl = actor.Uri;
var actorObject = new Dictionary<string, object> var actorObject = new Dictionary<string, object?>
{ {
["id"] = actorUrl, ["id"] = actorUrl,
["type"] = actor.Type, ["type"] = actor.Type,
@@ -325,7 +325,7 @@ public class ActivityPubDeliveryService(
["outbox"] = actor.OutboxUri, ["outbox"] = actor.OutboxUri,
["followers"] = actor.FollowersUri, ["followers"] = actor.FollowersUri,
["following"] = actor.FollowingUri, ["following"] = actor.FollowingUri,
["publicKey"] = new Dictionary<string, object> ["publicKey"] = new Dictionary<string, object?>
{ {
["id"] = actor.PublicKeyId, ["id"] = actor.PublicKeyId,
["owner"] = actorUrl, ["owner"] = actorUrl,
@@ -335,7 +335,7 @@ public class ActivityPubDeliveryService(
if (publisher.Picture != null) if (publisher.Picture != null)
{ {
actorObject["icon"] = new Dictionary<string, object> actorObject["icon"] = new Dictionary<string, object?>
{ {
["type"] = "Image", ["type"] = "Image",
["mediaType"] = publisher.Picture.MimeType, ["mediaType"] = publisher.Picture.MimeType,
@@ -345,7 +345,7 @@ public class ActivityPubDeliveryService(
if (publisher.Background != null) if (publisher.Background != null)
{ {
actorObject["image"] = new Dictionary<string, object> actorObject["image"] = new Dictionary<string, object?>
{ {
["type"] = "Image", ["type"] = "Image",
["mediaType"] = publisher.Background.MimeType, ["mediaType"] = publisher.Background.MimeType,
@@ -364,7 +364,7 @@ public class ActivityPubDeliveryService(
["type"] = "Update", ["type"] = "Update",
["actor"] = actorUrl, ["actor"] = actorUrl,
["published"] = DateTimeOffset.UtcNow, ["published"] = DateTimeOffset.UtcNow,
["to"] = new[] { "https://www.w3.org/ns/activitystreams#Public" }, ["to"] = Array.Empty<object>(),
["cc"] = new[] { $"{actorUrl}/followers" }, ["cc"] = new[] { $"{actorUrl}/followers" },
["object"] = actorObject ["object"] = actorObject
}; };