Skip to content

Commit

Permalink
Removed post only fields from pages
Browse files Browse the repository at this point in the history
- As we introduced email_subject and send_email_when_published for post responses we don't want to return them for pages
  • Loading branch information
naz committed Nov 5, 2019
1 parent d5aa384 commit d471001
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/server/api/canary/utils/serializers/output/pages.js
Expand Up @@ -12,15 +12,15 @@ module.exports = {

if (models.meta) {
frame.response = {
pages: models.data.map(model => mapper.mapPost(model, frame)),
pages: models.data.map(model => mapper.mapPage(model, frame)),
meta: models.meta
};

return;
}

frame.response = {
pages: [mapper.mapPost(models, frame)]
pages: [mapper.mapPage(models, frame)]
};
}
};
10 changes: 10 additions & 0 deletions core/server/api/canary/utils/serializers/output/utils/mapper.js
Expand Up @@ -75,6 +75,15 @@ const mapPost = (model, frame) => {
return jsonModel;
};

const mapPage = (model, frame) => {
const jsonModel = mapPost(model, frame);

delete jsonModel.email_subject;
delete jsonModel.send_email_when_published;

return jsonModel;
};

const mapSettings = (attrs, frame) => {
url.forSettings(attrs);
extraAttrs.forSettings(attrs, frame);
Expand Down Expand Up @@ -126,6 +135,7 @@ const mapMember = (model, frame) => {
};

module.exports.mapPost = mapPost;
module.exports.mapPage = mapPage;
module.exports.mapUser = mapUser;
module.exports.mapTag = mapTag;
module.exports.mapIntegration = mapIntegration;
Expand Down

0 comments on commit d471001

Please sign in to comment.