diff --git a/packages/xpub-faraday/config/authsome-mode.js b/packages/xpub-faraday/config/authsome-mode.js index 454a6170d127a5207cf8773e7b49c7d69b8219bf..d22fb6c8a4fb2324965f57662e67db57c0e4c3c0 100644 --- a/packages/xpub-faraday/config/authsome-mode.js +++ b/packages/xpub-faraday/config/authsome-mode.js @@ -68,6 +68,9 @@ function unauthenticatedUser(operation, object, userId) { const isCollectionInStatuses = (c, statuses) => statuses.includes(get(c, 'status', 'draft')) +const filterCollectionInStatuses = (statuses = []) => c => + !statuses.includes(get(c, 'status', 'draft')) + const filterNoFragmentCollections = c => c.fragments.length !== 0 const createPaths = ['/collections', '/collections/:collectionId/fragments'] @@ -378,7 +381,7 @@ async function applyEditorInChiefPolicy(user, operation, object, context) { const collections = await context.models.Collection.all() return Promise.all( collections - .filter(c => !isCollectionInStatuses(c, ['draft', 'technicalChecks'])) + .filter(filterCollectionInStatuses(['draft', 'technicalChecks'])) .filter(filterNoFragmentCollections) .map(async coll => { const latestFragmentId = coll.fragments[coll.fragments.length - 1]