0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Refactored Pages API v3/canary controllers

refs https://github.com/TryGhost/Team/issues/949
refs e64274bb45

- This refactor is needed to bring the code in line with the rest of pages API controllers
- Next step will extract shared code patterns into a separate module
This commit is contained in:
Naz 2021-08-05 14:42:16 +04:00
parent 87ad210624
commit accf0c645a
2 changed files with 42 additions and 44 deletions

View file

@ -147,9 +147,9 @@ module.exports = {
docName: 'posts',
unsafeAttrs: UNSAFE_ATTRS
},
query(frame) {
return models.Post.edit(frame.data.pages[0], frame.options)
.then((model) => {
async query(frame) {
const model = await models.Post.edit(frame.data.pages[0], frame.options);
if (
model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published'
@ -169,7 +169,6 @@ module.exports = {
}
return model;
});
}
},

View file

@ -147,9 +147,9 @@ module.exports = {
docName: 'posts',
unsafeAttrs: UNSAFE_ATTRS
},
query(frame) {
return models.Post.edit(frame.data.pages[0], frame.options)
.then((model) => {
async query(frame) {
const model = await models.Post.edit(frame.data.pages[0], frame.options);
if (
model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published'
@ -169,7 +169,6 @@ module.exports = {
}
return model;
});
}
},