mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Fixed order of flatten/clean operations in posts output serializers (#13038)
no issue `post.clean()` implementation was expecting a flat structure representing final API output but was being called before the flatten operation for `posts_meta` meaning the structure looked like `attrs.posts_meta.property` instead - adjusted order in output serializers to call `clean()` after flattening the `posts_meta` object - in `v2` output serializer, moved removal of properties from the serializer into `clean()` for consistency
This commit is contained in:
parent
f49f7699aa
commit
4e724b6451
4 changed files with 30 additions and 31 deletions
|
@ -47,6 +47,15 @@ const mapPost = (model, frame) => {
|
||||||
gating.forPost(jsonModel, frame);
|
gating.forPost(jsonModel, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transforms post/page metadata to flat structure
|
||||||
|
let metaAttrs = _.keys(_.omit(postsMetaSchema, ['id', 'post_id']));
|
||||||
|
_(metaAttrs).filter((k) => {
|
||||||
|
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
||||||
|
}).each((attr) => {
|
||||||
|
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
||||||
|
});
|
||||||
|
delete jsonModel.posts_meta;
|
||||||
|
|
||||||
clean.post(jsonModel, frame);
|
clean.post(jsonModel, frame);
|
||||||
|
|
||||||
if (frame.options && frame.options.withRelated) {
|
if (frame.options && frame.options.withRelated) {
|
||||||
|
@ -72,15 +81,6 @@ const mapPost = (model, frame) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transforms post/page metadata to flat structure
|
|
||||||
let metaAttrs = _.keys(_.omit(postsMetaSchema, ['id', 'post_id']));
|
|
||||||
_(metaAttrs).filter((k) => {
|
|
||||||
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
|
||||||
}).each((attr) => {
|
|
||||||
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
|
||||||
});
|
|
||||||
delete jsonModel.posts_meta;
|
|
||||||
|
|
||||||
return jsonModel;
|
return jsonModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,9 @@ const post = (attrs, frame) => {
|
||||||
delete attrs.locale;
|
delete attrs.locale;
|
||||||
delete attrs.author;
|
delete attrs.author;
|
||||||
delete attrs.type;
|
delete attrs.type;
|
||||||
|
delete attrs.send_email_when_published;
|
||||||
|
delete attrs.email_recipient_filter;
|
||||||
|
delete attrs.email_subject;
|
||||||
|
|
||||||
return attrs;
|
return attrs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,6 +50,15 @@ const mapPost = (model, frame) => {
|
||||||
gating.forPost(jsonModel, frame);
|
gating.forPost(jsonModel, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transforms post/page metadata to flat structure
|
||||||
|
let metaAttrs = _.keys(_.omit(postsMetaSchema, ['id', 'post_id']));
|
||||||
|
_(metaAttrs).filter((k) => {
|
||||||
|
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
||||||
|
}).each((attr) => {
|
||||||
|
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
||||||
|
});
|
||||||
|
delete jsonModel.posts_meta;
|
||||||
|
|
||||||
clean.post(jsonModel, frame);
|
clean.post(jsonModel, frame);
|
||||||
|
|
||||||
if (frame.options && frame.options.withRelated) {
|
if (frame.options && frame.options.withRelated) {
|
||||||
|
@ -67,19 +76,6 @@ const mapPost = (model, frame) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transforms post/page metadata to flat structure
|
|
||||||
let metaAttrs = _.keys(_.omit(postsMetaSchema, ['id', 'post_id']));
|
|
||||||
_(metaAttrs).filter((k) => {
|
|
||||||
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
|
||||||
}).each((attr) => {
|
|
||||||
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
|
||||||
});
|
|
||||||
|
|
||||||
delete jsonModel.posts_meta;
|
|
||||||
delete jsonModel.send_email_when_published;
|
|
||||||
delete jsonModel.email_recipient_filter;
|
|
||||||
delete jsonModel.email_subject;
|
|
||||||
|
|
||||||
return jsonModel;
|
return jsonModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,15 @@ const mapPost = (model, frame) => {
|
||||||
jsonModel.send_email_when_published = true;
|
jsonModel.send_email_when_published = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transforms post/page metadata to flat structure
|
||||||
|
let metaAttrs = _.keys(_.omit(postsMetaSchema, ['id', 'post_id']));
|
||||||
|
_(metaAttrs).filter((k) => {
|
||||||
|
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
||||||
|
}).each((attr) => {
|
||||||
|
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
||||||
|
});
|
||||||
|
delete jsonModel.posts_meta;
|
||||||
|
|
||||||
clean.post(jsonModel, frame);
|
clean.post(jsonModel, frame);
|
||||||
|
|
||||||
if (frame.options && frame.options.withRelated) {
|
if (frame.options && frame.options.withRelated) {
|
||||||
|
@ -80,15 +89,6 @@ const mapPost = (model, frame) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transforms post/page metadata to flat structure
|
|
||||||
let metaAttrs = _.keys(_.omit(postsMetaSchema, ['id', 'post_id']));
|
|
||||||
_(metaAttrs).filter((k) => {
|
|
||||||
return (!frame.options.columns || (frame.options.columns && frame.options.columns.includes(k)));
|
|
||||||
}).each((attr) => {
|
|
||||||
jsonModel[attr] = _.get(jsonModel.posts_meta, attr) || null;
|
|
||||||
});
|
|
||||||
delete jsonModel.posts_meta;
|
|
||||||
|
|
||||||
return jsonModel;
|
return jsonModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue