mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
Used Article as Activity object
ref https://linear.app/tryghost/issue/MOM-126 This allows us to pull out all of the data when converting to JSONLD
This commit is contained in:
parent
8842dc2312
commit
ea40c6ad65
@ -1,4 +1,5 @@
|
||||
import {Entity} from '../../common/entity.base';
|
||||
import {Article} from './article.object';
|
||||
import {ActivityPub} from './types';
|
||||
import {URI} from './uri.object';
|
||||
|
||||
@ -11,7 +12,7 @@ type ActivityData = {
|
||||
type: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
[x: string]: any;
|
||||
};
|
||||
} | Article;
|
||||
to: URI | null;
|
||||
}
|
||||
|
||||
@ -45,7 +46,10 @@ export class Activity extends Entity<ActivityData> {
|
||||
return this.attr.type;
|
||||
}
|
||||
|
||||
getObject() {
|
||||
getObject(url: URL) {
|
||||
if (this.attr.object instanceof Article) {
|
||||
return this.attr.object.getJSONLD(url);
|
||||
}
|
||||
return this.attr.object;
|
||||
}
|
||||
|
||||
@ -54,6 +58,9 @@ export class Activity extends Entity<ActivityData> {
|
||||
}
|
||||
|
||||
get objectId() {
|
||||
if (this.attr.object instanceof Article) {
|
||||
return this.attr.object.objectId;
|
||||
}
|
||||
return this.attr.object.id;
|
||||
}
|
||||
|
||||
@ -62,7 +69,7 @@ export class Activity extends Entity<ActivityData> {
|
||||
}
|
||||
|
||||
getJSONLD(url: URL): ActivityPub.Activity {
|
||||
const object = this.getObject();
|
||||
const object = this.getObject(url);
|
||||
return {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: this.activityId?.getValue(url) || null,
|
||||
|
@ -157,10 +157,7 @@ export class Actor extends Entity<ActorData> {
|
||||
to: this.followersCollectionId,
|
||||
type: 'Create',
|
||||
actor: this.actorId,
|
||||
object: {
|
||||
id: article.objectId,
|
||||
type: 'Article'
|
||||
}
|
||||
object: article
|
||||
});
|
||||
this.doActivity(activity);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user