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