Removed API versioning from webhooks

refs: https://github.com/TryGhost/Toolbox/issues/229
refs: https://github.com/TryGhost/Toolbox/issues/283

- we are getting rid of the concept of having multiple api versions in a single ghost install
- we'll update webhooks to return a content version
- we're also looking into if we need some sort of accept-version type logic
This commit is contained in:
Hannah Wolfe 2022-04-08 15:51:22 +01:00 committed by Daniel Lockyer
parent 923d436f11
commit 1fbb8a219f
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD

View File

@ -1,9 +1,7 @@
module.exports = (event, model) => {
const _ = require('lodash');
const {sequence} = require('@tryghost/promise');
const api = require('../../api');
const apiVersion = model.get('api_version') || 'v4';
const api = require('../../api').canary;
const resourceName = event.match(/(\w+)\./)[1];
const docName = `${resourceName}s`;
@ -22,7 +20,7 @@ module.exports = (event, model) => {
return api.shared
.serializers
.handle
.output(model, {docName: docName, method: 'read'}, api[apiVersion].serializers.output, frame)
.output(model, {docName: docName, method: 'read'}, api.serializers.output, frame)
.then(() => {
return frame.response[docName][0];
});
@ -45,7 +43,7 @@ module.exports = (event, model) => {
return api.shared
.serializers
.handle
.output(model, {docName: docName, method: 'read'}, api[apiVersion].serializers.output, frame)
.output(model, {docName: docName, method: 'read'}, api.serializers.output, frame)
.then(() => {
return frame.response[docName][0];
});