Started work on tabletop view
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import Parties from '/imports/api/campaign/Parties.js';
|
||||
import Parties from '/imports/api/creature/Parties.js';
|
||||
|
||||
Meteor.publish('characterList', function(){
|
||||
this.autorun(function (){
|
||||
|
||||
@@ -5,3 +5,4 @@ import '/imports/server/publications/singleCharacter.js';
|
||||
import '/imports/server/publications/experiences.js';
|
||||
import '/imports/server/publications/users.js';
|
||||
import '/imports/server/publications/icons.js';
|
||||
import '/imports/server/publications/tabletops.js';
|
||||
|
||||
51
app/imports/server/publications/tabletops.js
Normal file
51
app/imports/server/publications/tabletops.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import Tabletops from '/imports/api/tabletop/Tabletops.js';
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
|
||||
Meteor.publish('tabletops', function(){
|
||||
var userId = this.userId;
|
||||
if (!userId) {
|
||||
return this.ready();
|
||||
}
|
||||
return Tabletops.find({
|
||||
$or: [
|
||||
{players: userId},
|
||||
{gameMaster: userId},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('tabletop', function(tabletopId){
|
||||
var userId = this.userId;
|
||||
if (!userId) {
|
||||
return this.ready();
|
||||
}
|
||||
this.autorun(function (){
|
||||
let tabletopCursor = Tabletops.find({
|
||||
_id: tabletopId,
|
||||
$or: [
|
||||
{players: userId},
|
||||
{gameMaster: userId},
|
||||
]
|
||||
});
|
||||
let tabletop = tabletopCursor.fetch()[0];
|
||||
if (!tabletop){
|
||||
return this.ready();
|
||||
}
|
||||
// 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
|
||||
let creatureSummaries = Creatures.find({
|
||||
tabletop: tabletopId,
|
||||
}, {
|
||||
fields: {
|
||||
name: 1,
|
||||
picture: 1,
|
||||
avatarPicture: 1,
|
||||
variables: 1,
|
||||
tabletop: 1,
|
||||
initiativeRoll: 1,
|
||||
},
|
||||
});
|
||||
return [ tabletopCursor, creatureSummaries]
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user