diff --git a/core/server/api/v2/utils/serializers/input/posts.js b/core/server/api/v2/utils/serializers/input/posts.js index 6a4d271d61..a887c9a211 100644 --- a/core/server/api/v2/utils/serializers/input/posts.js +++ b/core/server/api/v2/utils/serializers/input/posts.js @@ -108,30 +108,6 @@ module.exports = { delete frame.data.posts[0].author; } - /** - * CASE: we don't support updating nested-nested relations e.g. `post.authors[*].roles` yet. - * - * Bookshelf-relations supports this feature, BUT bookshelf's `hasChanged` fn will currently - * clash with this, because `hasChanged` won't be able to tell if relations have changed or not. - * It would always return `changed.roles = [....]`. It would always throw a model event that relations - * were updated, which is not true. - * - * Bookshelf-relations can tell us if a relation has changed, it knows that. - * But the connection between our model layer, Bookshelf's `hasChanged` fn and Bookshelf-relations - * is not present. As long as we don't support this case, we have to ignore this. - */ - if (frame.data.posts[0].authors && frame.data.posts[0].authors.length) { - _.each(frame.data.posts[0].authors, (author, index) => { - if (author.hasOwnProperty('roles')) { - delete frame.data.posts[0].authors[index].roles; - } - - if (author.hasOwnProperty('permissions')) { - delete frame.data.posts[0].authors[index].permissions; - } - }); - } - /** * Model notation is: `tag.parent_id`. * The API notation is `tag.parent`. diff --git a/core/server/api/v2/utils/validators/input/schemas/posts.json b/core/server/api/v2/utils/validators/input/schemas/posts.json index a0ebfb4814..2049934c5d 100644 --- a/core/server/api/v2/utils/validators/input/schemas/posts.json +++ b/core/server/api/v2/utils/validators/input/schemas/posts.json @@ -142,6 +142,12 @@ "email": { "type": "string", "maxLength": 191 + }, + "roles": { + "strip": true + }, + "permissions": { + "strip": true } }, "anyOf": [