86 lines
3.5 KiB
JavaScript
86 lines
3.5 KiB
JavaScript
import Characters from "/imports/api/creature/Creatures.js";
|
|
import Actions from "/imports/api/creature/properties/Actions.js";
|
|
import Attacks from "/imports/api/creature/properties/Attacks.js";
|
|
import Attributes from "/imports/api/creature/properties/Attributes.js";
|
|
import Buffs from "/imports/api/creature/properties/Buffs.js";
|
|
import Classes from "/imports/api/creature/properties/Classes.js";
|
|
import Conditions from "/imports/api/creature/properties/Conditions.js";
|
|
import CustomBuffs from "/imports/api/creature/properties/CustomBuffs.js";
|
|
import DamageMultipliers from "/imports/api/creature/properties/DamageMultipliers.js";
|
|
import Effects from "/imports/api/creature/properties/Effects.js";
|
|
import Experiences from "/imports/api/creature/properties/Experiences.js";
|
|
import Features from "/imports/api/creature/properties/Features.js";
|
|
import Notes from "/imports/api/creature/properties/Notes.js";
|
|
import Skills from "/imports/api/creature/properties/Skills.js";
|
|
import Spells from "/imports/api/creature/properties/Spells.js";
|
|
import SpellLists from "/imports/api/creature/properties/SpellLists.js";
|
|
import Proficiencies from "/imports/api/creature/properties/Proficiencies.js";
|
|
import Containers from "/imports/api/inventory/Containers.js";
|
|
import Items from "/imports/api/inventory/Items.js";
|
|
|
|
Meteor.publish("singleCharacter", function(characterId){
|
|
userId = this.userId;
|
|
var char = Characters.findOne({
|
|
_id: characterId,
|
|
$or: [
|
|
{readers: userId},
|
|
{writers: userId},
|
|
{owner: userId},
|
|
{"settings.viewPermission": "public"},
|
|
],
|
|
});
|
|
if (char){
|
|
return [
|
|
Characters.find({_id: characterId}),
|
|
//get all the assets for this character including soft deleted ones
|
|
Actions.find ({charId: characterId}, {removed: true}),
|
|
Attacks.find ({charId: characterId}, {removed: true}),
|
|
Attributes.find ({charId: characterId}, {removed: true}),
|
|
Buffs.find ({charId: characterId}, {removed: true}),
|
|
Classes.find ({charId: characterId}, {removed: true}),
|
|
Conditions.find ({charId: characterId}, {removed: true}),
|
|
Containers.find ({charId: characterId}, {removed: true}),
|
|
CustomBuffs.find ({charId: characterId}, {removed: true}),
|
|
DamageMultipliers.find ({charId: characterId}, {removed: true}),
|
|
Effects.find ({charId: characterId}, {removed: true}),
|
|
Experiences.find ({charId: characterId}, {removed: true}),
|
|
Features.find ({charId: characterId}, {removed: true}),
|
|
Items.find ({charId: characterId}, {removed: true}),
|
|
Notes.find ({charId: characterId}, {removed: true}),
|
|
Skills.find ({charId: characterId}, {removed: true}),
|
|
Spells.find ({charId: characterId}, {removed: true}),
|
|
SpellLists.find ({charId: characterId}, {removed: true}),
|
|
TemporaryHitPoints.find ({charId: characterId}, {removed: true}),
|
|
Proficiencies.find ({charId: characterId}, {removed: true}),
|
|
];
|
|
} else {
|
|
return [];
|
|
}
|
|
});
|
|
|
|
DDPRateLimiter.addRule({
|
|
name: "singleCharacter",
|
|
type: "subscription",
|
|
userId: null,
|
|
connectionId(){ return true; },
|
|
}, 8, 10000, function(reply, ruleInput){
|
|
if(!reply.allowed){
|
|
logRateError(reply, ruleInput);
|
|
}
|
|
});
|
|
|
|
Meteor.publish("singleCharacterName", function(characterId){
|
|
userId = this.userId;
|
|
return Characters.find({
|
|
_id: characterId,
|
|
$or: [
|
|
{readers: userId},
|
|
{writers: userId},
|
|
{owner: userId},
|
|
{"settings.viewPermission": "public"},
|
|
],
|
|
}, {
|
|
fields:{"name": 1}
|
|
});
|
|
});
|