Added CollectionPost events
refs https://github.com/TryGhost/Arch/issues/95 These events can be used to know when an automatic collections posts have been updated, as well as by the repository to optimise the storage of CollectionPosts
This commit is contained in:
parent
22029bfd1b
commit
637724ba66
19
ghost/collections/src/events/CollectionPostAdded.ts
Normal file
19
ghost/collections/src/events/CollectionPostAdded.ts
Normal file
@ -0,0 +1,19 @@
|
||||
type CollectionPostAddedData = {
|
||||
collection_id: string;
|
||||
post_id: string;
|
||||
};
|
||||
|
||||
export class CollectionPostAdded {
|
||||
data: CollectionPostAddedData;
|
||||
timestamp: Date;
|
||||
type = 'CollectionPostAdded' as const;
|
||||
|
||||
constructor(data: CollectionPostAddedData, timestamp: Date) {
|
||||
this.data = data;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
static create(data: CollectionPostAddedData, timestamp = new Date()) {
|
||||
return new CollectionPostAdded(data, timestamp);
|
||||
}
|
||||
}
|
19
ghost/collections/src/events/CollectionPostRemoved.ts
Normal file
19
ghost/collections/src/events/CollectionPostRemoved.ts
Normal file
@ -0,0 +1,19 @@
|
||||
type CollectionPostRemovedData = {
|
||||
collection_id: string;
|
||||
post_id: string;
|
||||
};
|
||||
|
||||
export class CollectionPostRemoved {
|
||||
data: CollectionPostRemovedData;
|
||||
timestamp: Date;
|
||||
type = 'CollectionPostRemoved' as const;
|
||||
|
||||
constructor(data: CollectionPostRemovedData, timestamp: Date) {
|
||||
this.data = data;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
static create(data: CollectionPostRemovedData, timestamp = new Date()) {
|
||||
return new CollectionPostRemoved(data, timestamp);
|
||||
}
|
||||
}
|
@ -4,3 +4,5 @@ export * from './Collection';
|
||||
export * from './events/PostAddedEvent';
|
||||
export * from './events/PostEditedEvent';
|
||||
export * from './events/TagDeletedEvent';
|
||||
export * from './events/CollectionPostAdded';
|
||||
export * from './events/CollectionPostRemoved';
|
||||
|
Loading…
Reference in New Issue
Block a user