diff --git a/ghost/ghost/src/core/activitypub/activity.entity.ts b/ghost/ghost/src/core/activitypub/activity.entity.ts index 86c2e28381..5fc9d3b8eb 100644 --- a/ghost/ghost/src/core/activitypub/activity.entity.ts +++ b/ghost/ghost/src/core/activitypub/activity.entity.ts @@ -6,8 +6,12 @@ type ActivityData = { activity: URI | null; type: ActivityPub.ActivityType; actor: URI; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - object: {id: URI, [x: string]: any}; + object: { + id: URI; + type: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [x: string]: any; + }; to: URI | null; } @@ -58,6 +62,7 @@ export class Activity extends Entity { } getJSONLD(url: URL): ActivityPub.Activity { + const object = this.getObject(); return { '@context': 'https://www.w3.org/ns/activitystreams', id: this.activityId?.getValue(url) || null, @@ -67,7 +72,10 @@ export class Activity extends Entity { id: this.actorId.getValue(url), username: `@index@${this.actorId.hostname}` }, - object: this.objectId.getValue(url), + object: { + ...object, + id: this.objectId.getValue(url) + }, to: this.attr.to?.getValue(url) || null }; } @@ -81,7 +89,10 @@ export class Activity extends Entity { activity: 'id' in json ? getURI(json.id) : null, type: parsed.type as ActivityPub.ActivityType, actor: getURI(parsed.actor), - object: {id: getURI(parsed.object)}, + object: { + id: getURI(parsed.object), + type: 'Unknown' + }, to: 'to' in json ? getURI(json.to) : null }); } diff --git a/ghost/ghost/src/core/activitypub/actor.entity.test.ts b/ghost/ghost/src/core/activitypub/actor.entity.test.ts index 87d5db6c3c..30d725a8ca 100644 --- a/ghost/ghost/src/core/activitypub/actor.entity.test.ts +++ b/ghost/ghost/src/core/activitypub/actor.entity.test.ts @@ -125,7 +125,10 @@ describe('Actor', function () { activity: new URI(`https://activitypub.server/activity`), type: 'Follow', actor: newFollower, - object: {id: actor.actorId}, + object: { + id: actor.actorId, + type: 'Person' + }, to: actor.actorId }); @@ -143,7 +146,10 @@ describe('Actor', function () { activity: null, type: 'Follow', actor: newFollower, - object: {id: actor.actorId}, + object: { + id: actor.actorId, + type: 'Person' + }, to: actor.actorId }); @@ -167,7 +173,8 @@ describe('Actor', function () { type: 'Accept', actor: newFollower, object: { - id: newFollower + id: newFollower, + type: 'Person' }, to: actor.actorId }); diff --git a/ghost/ghost/src/core/activitypub/actor.entity.ts b/ghost/ghost/src/core/activitypub/actor.entity.ts index 51f55c59a2..af0c808eb7 100644 --- a/ghost/ghost/src/core/activitypub/actor.entity.ts +++ b/ghost/ghost/src/core/activitypub/actor.entity.ts @@ -110,7 +110,10 @@ export class Actor extends Entity { activity: new URI(`activity/${(new ObjectID).toHexString()}`), type: 'Follow', actor: this.actorId, - object: actor, + object: { + ...actor, + type: 'Person' + }, to: actor.id }); this.doActivity(activity); @@ -126,7 +129,10 @@ export class Actor extends Entity { type: 'Accept', to: activity.actorId, actor: this.actorId, - object: {id: activity.activityId} + object: { + id: activity.activityId, + type: 'Follow' + } }); this.doActivity(accept); } @@ -151,7 +157,10 @@ export class Actor extends Entity { to: this.followersCollectionId, type: 'Create', actor: this.actorId, - object: {id: article.objectId} + object: { + id: article.objectId, + type: 'Article' + } }); this.doActivity(activity); } diff --git a/ghost/ghost/src/core/activitypub/inbox.service.test.ts b/ghost/ghost/src/core/activitypub/inbox.service.test.ts index 972b8f28d3..11b3c15973 100644 --- a/ghost/ghost/src/core/activitypub/inbox.service.test.ts +++ b/ghost/ghost/src/core/activitypub/inbox.service.test.ts @@ -27,6 +27,7 @@ describe('InboxService', function () { type: 'Follow', activity: null, object: { + type: 'Application', id: new URI('https://whatever.com') }, actor: new URI('https://blak.com'), @@ -59,6 +60,7 @@ describe('InboxService', function () { type: 'Follow', activity: null, object: { + type: 'Person', id: new URI('https://whatever.com') }, actor: new URI('https://blak.com'), diff --git a/ghost/ghost/src/core/activitypub/tell-the-world.service.test.ts b/ghost/ghost/src/core/activitypub/tell-the-world.service.test.ts index 08bec6954b..e2c21a2ba2 100644 --- a/ghost/ghost/src/core/activitypub/tell-the-world.service.test.ts +++ b/ghost/ghost/src/core/activitypub/tell-the-world.service.test.ts @@ -27,6 +27,7 @@ describe('TheWorld', function () { activity: null, actor: actor.actorId, object: { + type: 'Person', id: toFollow }, to: toFollow diff --git a/ghost/ghost/src/listeners/activity.listener.test.ts b/ghost/ghost/src/listeners/activity.listener.test.ts index 6882987c19..a34f8ec45c 100644 --- a/ghost/ghost/src/listeners/activity.listener.test.ts +++ b/ghost/ghost/src/listeners/activity.listener.test.ts @@ -30,6 +30,7 @@ describe('ActivityListener', function () { activity: null, actor: actor.actorId, object: { + type: 'Person', id: toFollow }, to: toFollow