Skip to content

Commit

Permalink
Limited legacy subscriber webhook payload to v2 only (#11139)
Browse files Browse the repository at this point in the history
no issue

- In v3 we don't need to support any legacy webhook formats
- Added a comment about the removal of the format when v2 is dropped
  • Loading branch information
naz authored Sep 18, 2019
1 parent 3b65081 commit 6f9026a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions core/server/services/webhooks/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,17 @@ module.exports = (event, model) => {
}
};

// @TODO: remove in v3
// @NOTE: Our webhook format has changed, we still have to support the old format for subscribers events
if ('subscriber.added' === event) {
payload[docName] = [current];
}
// @NOTE: Our webhook format has changed, we still have to support the old format
// for subscribers events. No need to support it passed v2 version
// @TODO: Remove whole if block when dropping Ghost v2
if (apiVersion === 'v2') {
if ('subscriber.added' === event) {
payload[docName] = [current];
}

if ('subscriber.deleted' === event) {
payload[docName] = [previous];
if ('subscriber.deleted' === event) {
payload[docName] = [previous];
}
}

return payload;
Expand Down

0 comments on commit 6f9026a

Please sign in to comment.