Iterated on tabletops

This commit is contained in:
Thaum Rystra
2024-06-12 17:30:37 +02:00
parent a5292cf0f2
commit 621f284cff
12 changed files with 210 additions and 56 deletions

View File

@@ -4,6 +4,8 @@ import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
import { assertUserInTabletop } from './shared/tabletopPermissions';
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers';
import Creatures from '/imports/api/creature/creatures/Creatures';
import Tabletops from '/imports/api/tabletop/Tabletops';
import { assertTabletopHasPropSpace } from '/imports/api/tabletop/methods/shared/tabletopLimits';
const addCreaturesToTabletop = new ValidatedMethod({
@@ -12,6 +14,7 @@ const addCreaturesToTabletop = new ValidatedMethod({
validate: new SimpleSchema({
'creatureIds': {
type: Array,
max: 20,
},
'creatureIds.$': {
type: String,
@@ -24,7 +27,6 @@ const addCreaturesToTabletop = new ValidatedMethod({
}).validator(),
mixins: [RateLimiterMixin],
// @ts-expect-error Rate limit not defined
rateLimit: {
numRequests: 10,
timeInterval: 5000,
@@ -36,7 +38,9 @@ const addCreaturesToTabletop = new ValidatedMethod({
'You need to be logged in to remove a tabletop');
}
assertUserHasPaidBenefits(this.userId);
assertUserInTabletop(tabletopId, this.userId);
const tabletop = Tabletops.findOne(tabletopId);
assertUserInTabletop(tabletop, this.userId);
assertTabletopHasPropSpace(tabletop);
Creatures.update({
_id: { $in: creatureIds },