Skip to content
Snippets Groups Projects
Commit b54657f9 authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

fix reviewer files filter

parent 5507b2ff
No related branches found
No related tags found
1 merge request!8Sprint #10
...@@ -27,7 +27,11 @@ const filterRefusedInvitations = (coll, user) => { ...@@ -27,7 +27,11 @@ const filterRefusedInvitations = (coll, user) => {
return coll return coll
} }
const filterObjectData = (collectionsPermissions, object, user) => { const filterObjectData = (
collectionsPermissions = [],
object = {},
user = {},
) => {
if (object.type === 'fragment') { if (object.type === 'fragment') {
const matchingCollPerm = collectionsPermissions.find( const matchingCollPerm = collectionsPermissions.find(
collPerm => object.id === collPerm.fragmentId, collPerm => object.id === collPerm.fragmentId,
......
...@@ -16,18 +16,21 @@ async function teamPermissions(user, operation, object, context) { ...@@ -16,18 +16,21 @@ async function teamPermissions(user, operation, object, context) {
return null return null
}), }),
) )
const objectType = get(object, 'type')
let fragmentId = null const collectionsPermissions = Promise.all(
if (objectType !== undefined) { teams.filter(Boolean).map(async team => {
if (objectType === 'fragment') { const collection = await context.models.Collection.find(team.object.id)
fragmentId = object.id const collPerm = {
} id: collection.id,
} permission: team.teamType.permissions,
const collectionsPermissions = teams.filter(Boolean).map(team => ({ }
id: team.object.id, const objectType = get(object, 'type')
permission: team.teamType.permissions, if (objectType === 'fragment' && collection.fragments.includes(object.id))
fragmentId, collPerm.fragmentId = object.id
}))
return collPerm
}),
)
if (collectionsPermissions.length === 0) return {} if (collectionsPermissions.length === 0) return {}
......
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