Skip to content

Commit

Permalink
Added CollectionPost events
Browse files Browse the repository at this point in the history
refs TryGhost/Arch#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
  • Loading branch information
allouis committed Sep 22, 2023
1 parent 22029bf commit 637724b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ghost/collections/src/events/CollectionPostAdded.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions ghost/collections/src/events/CollectionPostRemoved.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 2 additions & 0 deletions ghost/collections/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 637724b

Please sign in to comment.