Updated comment API to only return top-level comments

refs https://github.com/TryGhost/Team/issues/1664

- we will have a separate concept of returning replies
This commit is contained in:
Hannah Wolfe 2022-07-06 16:06:41 +02:00 committed by Simon Backx
parent 0d4b3a2baa
commit cf529111f6
3 changed files with 8 additions and 19 deletions

View File

@ -48,7 +48,12 @@ const Comment = ghostBookshelf.Model.extend({
}
model.emitChange('added', options);
},
enforcedFilters: function enforcedFilters() {
return 'parent_id:null';
}
}, {
destroy: function destroy(unfilteredOptions) {
let options = this.filterOptions(unfilteredOptions, 'destroy', {extraAllowedProperties: ['id']});

View File

@ -19,22 +19,6 @@ Object {
},
"status": "published",
},
Object {
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
"edited_at": null,
"html": "<p>Really original</p>",
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
"liked": Any<Boolean>,
"likes_count": Any<Number>,
"member": Object {
"avatar_image": null,
"bio": null,
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
"name": null,
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
},
"status": "published",
},
Object {
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
"edited_at": null,
@ -59,7 +43,7 @@ Object {
"page": 1,
"pages": 1,
"prev": null,
"total": 3,
"total": 2,
},
},
}
@ -69,7 +53,7 @@ exports[`Comments API when authenticated Can browse all comments of a post 2: [h
Object {
"access-control-allow-origin": "*",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "1010",
"content-length": "704",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Accept-Encoding",

View File

@ -69,7 +69,7 @@ describe('Comments API', function () {
etag: anyEtag
})
.matchBodySnapshot({
comments: new Array(3).fill(commentMatcherWithMember)
comments: new Array(2).fill(commentMatcherWithMember)
});
});