Skip to content
Snippets Groups Projects
Commit d630804b authored by Mihail Hagiu's avatar Mihail Hagiu
Browse files

fix(authsome-mode): Refactor

parent e27a9c1b
No related branches found
No related tags found
3 merge requests!222Sprint #26,!217Sprint #26,!195feat(authsome-mode): Added rule for PATCH collection
......@@ -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]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment