From d630804b299bf2117266b34dfb23905fba8e7cc5 Mon Sep 17 00:00:00 2001
From: Mihail Hagiu <mihail.hagiu@thinslices.com>
Date: Wed, 12 Dec 2018 11:13:03 +0200
Subject: [PATCH] fix(authsome-mode): Refactor

---
 packages/xpub-faraday/config/authsome-mode.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/packages/xpub-faraday/config/authsome-mode.js b/packages/xpub-faraday/config/authsome-mode.js
index 454a6170d..d22fb6c8a 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]
-- 
GitLab