Merge branch 'feature-tabletop' into develop
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import Tabletops from '/imports/api/tabletop/Tabletops';
|
||||
import Creatures from '/imports/api/creature/creatures/Creatures';
|
||||
import Messages from '/imports/api/tabletop/Messages';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
|
||||
import CreatureLogs from '/imports/api/creature/log/CreatureLogs';
|
||||
import CreatureVariables from '/imports/api/creature/creatures/CreatureVariables';
|
||||
import { loadCreature } from '/imports/api/engine/loadCreatures';
|
||||
|
||||
Meteor.publish('tabletops', function () {
|
||||
var userId = this.userId;
|
||||
@@ -21,6 +24,7 @@ Meteor.publish('tabletop', function (tabletopId) {
|
||||
return [];
|
||||
}
|
||||
this.autorun(function () {
|
||||
const self = this;
|
||||
let tabletopCursor = Tabletops.find({
|
||||
_id: tabletopId,
|
||||
$or: [
|
||||
@@ -32,6 +36,7 @@ Meteor.publish('tabletop', function (tabletopId) {
|
||||
if (!tabletop) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Warning, this leaks data to users of the same tabletop who may not have
|
||||
// read permission of this specific creature, so publish as few fields as
|
||||
// possible
|
||||
@@ -39,22 +44,32 @@ Meteor.publish('tabletop', function (tabletopId) {
|
||||
tabletop: tabletopId,
|
||||
}, {
|
||||
fields: {
|
||||
_id: 1,
|
||||
name: 1,
|
||||
picture: 1,
|
||||
avatarPicture: 1,
|
||||
variables: 1,
|
||||
tabletop: 1,
|
||||
initiativeRoll: 1,
|
||||
settings: 1,
|
||||
},
|
||||
});
|
||||
let recentMessages = Messages.find({
|
||||
const creatureIds = creatureSummaries.map(c => c._id);
|
||||
creatureIds.forEach(creatureId => {
|
||||
loadCreature(creatureId, self);
|
||||
});
|
||||
const variables = CreatureVariables.find({
|
||||
_creatureId: { $in: creatureIds }
|
||||
});
|
||||
let properties = CreatureProperties.find({
|
||||
'ancestors.id': { $in: creatureIds },
|
||||
removed: { $ne: true },
|
||||
});
|
||||
const logs = CreatureLogs.find({
|
||||
tabletopId,
|
||||
}, {
|
||||
sort: {
|
||||
timeStamp: -1,
|
||||
},
|
||||
limit: 100,
|
||||
sort: { date: -1 },
|
||||
});
|
||||
return [tabletopCursor, creatureSummaries, recentMessages]
|
||||
return [tabletopCursor, creatureSummaries, properties, logs, variables]
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user