0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Updated tags output serialiasation for v2 API

no-issue

This ensures that the v2 API only outputs the tag properties we specify,
and doesn't include any new fields, like the new metadata columns.
This commit is contained in:
Fabien O'Carroll 2020-07-08 14:47:44 +02:00 committed by Fabien 'egg' O'Carroll
parent 7e5292eccc
commit a3f693b472
2 changed files with 32 additions and 14 deletions

View file

@ -3,25 +3,43 @@ const localUtils = require('../../../index');
const tag = (attrs, frame) => {
if (localUtils.isContentAPI(frame)) {
delete attrs.created_at;
delete attrs.updated_at;
const contentAttrs = _.pick(attrs, [
'description',
'feature_image',
'id',
'meta_description',
'meta_title',
'name',
'slug',
'url',
'visibility'
]);
// We are standardising on returning null from the Content API for any empty values
if (attrs.meta_title === '') {
attrs.meta_title = null;
if (contentAttrs.meta_title === '') {
contentAttrs.meta_title = null;
}
if (attrs.meta_description === '') {
attrs.meta_description = null;
if (contentAttrs.meta_description === '') {
contentAttrs.meta_description = null;
}
if (attrs.description === '') {
attrs.description = null;
if (contentAttrs.description === '') {
contentAttrs.description = null;
}
}
delete attrs.parent_id;
delete attrs.parent;
return attrs;
return _.pick(attrs, [
'created_at',
'description',
'feature_image',
'id',
'meta_description',
'meta_title',
'name',
'slug',
'updated_at',
'url',
'visibility'
]);
};
const author = (attrs, frame) => {

View file

@ -21,9 +21,9 @@ const mapTag = (model, frame) => {
const jsonModel = model.toJSON ? model.toJSON(frame.options) : model;
url.forTag(model.id, jsonModel, frame.options);
clean.tag(jsonModel, frame);
const cleanedAttrs = clean.tag(jsonModel, frame);
return jsonModel;
return cleanedAttrs;
};
const mapPost = (model, frame) => {