Fixed class level up w/ subscribed collections

This commit is contained in:
Stefan Zermatten
2022-08-17 12:45:54 +02:00
parent 21629138f0
commit ca18ffb565

View File

@@ -100,21 +100,18 @@ Meteor.publish('classFillers', function(classId){
} }
// Get all the ids of libraries the user can access // Get all the ids of libraries the user can access
const user = Meteor.users.findOne(userId, { const creatureId = classProp.ancestors[0].id;
fields: {subscribedLibraries: 1} const libraryIds = getCreatureLibraryIds(creatureId, userId);
}); const libraries = Libraries.find({
const subs = user && user.subscribedLibraries || [];
let libraries = Libraries.find({
$or: [ $or: [
{owner: userId}, { owner: userId },
{writers: userId}, { writers: userId },
{readers: userId}, { readers: userId },
{_id: {$in: subs}}, { _id: { $in: libraryIds }, public: true },
] ]
}, { }, {
fields: {_id: 1, name: 1}, sort: { name: 1 }
}); });
let libraryIds = libraries.map(lib => lib._id);
// Build a filter for nodes in those libraries that match the slot // Build a filter for nodes in those libraries that match the slot
let filter = getSlotFillFilter({slot: classProp, libraryIds}); let filter = getSlotFillFilter({slot: classProp, libraryIds});