diff --git a/ghost/ghost/src/core/activitypub/actor.entity.ts b/ghost/ghost/src/core/activitypub/actor.entity.ts index f93a28c746..cd59e32b98 100644 --- a/ghost/ghost/src/core/activitypub/actor.entity.ts +++ b/ghost/ghost/src/core/activitypub/actor.entity.ts @@ -13,43 +13,44 @@ type CreateActorData = ActorData & { id? : ObjectID }; -function makeUrl(base: URL, props: Map): URL { - const url = new URL(base.href); - for (const [key, value] of props.entries()) { - url.searchParams.set(key, value); +function makeUrl(base: URL, props: Record): URL { + const url = new URL(`${props.type}`, base.href); + for (const [key, value] of Object.entries(props)) { + if (key !== 'type') { + url.searchParams.set(key, value); + } } return url; } -function toMap(obj: Record): Map { - return new Map(Object.entries(obj)); -} - export class Actor extends Entity { get username() { return this.attr.username; } getJSONLD(url: URL): ActivityPub.Actor & ActivityPub.RootObject { - const actor = makeUrl(url, toMap({ + if (!url.href.endsWith('/')) { + url.href += '/'; + } + const actor = makeUrl(url, { type: 'actor', id: this.id.toHexString() - })); + }); - const publicKey = makeUrl(url, toMap({ + const publicKey = makeUrl(url, { type: 'key', owner: this.id.toHexString() - })); + }); - const inbox = makeUrl(url, toMap({ + const inbox = makeUrl(url, { type: 'inbox', owner: this.id.toHexString() - })); + }); - const outbox = makeUrl(url, toMap({ + const outbox = makeUrl(url, { type: 'outbox', owner: this.id.toHexString() - })); + }); return { '@context': 'https://www.w3.org/ns/activitystreams',