Removed .js from all imports to smooth ts migration
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||
import { assertUserInTabletop } from './shared/tabletopPermissions.js';
|
||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers.js';
|
||||
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||
import { assertUserInTabletop } from './shared/tabletopPermissions';
|
||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions';
|
||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers';
|
||||
import Creatures from '/imports/api/creature/creatures/Creatures';
|
||||
|
||||
const addCreaturesToTabletop = new ValidatedMethod({
|
||||
|
||||
@@ -30,23 +30,23 @@ const addCreaturesToTabletop = new ValidatedMethod({
|
||||
timeInterval: 5000,
|
||||
},
|
||||
|
||||
run({tabletopId, creatureIds}) {
|
||||
run({ tabletopId, creatureIds }) {
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('tabletops.addCreatures.denied',
|
||||
'You need to be logged in to remove a tabletop');
|
||||
'You need to be logged in to remove a tabletop');
|
||||
}
|
||||
assertUserHasPaidBenefits(this.userId);
|
||||
assertUserInTabletop(tabletopId, this.userId);
|
||||
assertAdmin(this.userId);
|
||||
|
||||
Creatures.update({
|
||||
_id: {$in: creatureIds},
|
||||
_id: { $in: creatureIds },
|
||||
$or: [
|
||||
{writers: this.userId},
|
||||
{owner: this.userId},
|
||||
{ writers: this.userId },
|
||||
{ owner: this.userId },
|
||||
],
|
||||
}, {
|
||||
$set: {tabletop: tabletopId},
|
||||
$set: { tabletop: tabletopId },
|
||||
}, {
|
||||
multi: true,
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||
import Tabletops from '../Tabletops.js';
|
||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers.js';
|
||||
import Tabletops from '../Tabletops';
|
||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions';
|
||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers';
|
||||
|
||||
const insertTabletop = new ValidatedMethod({
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||
import Tabletops from '../Tabletops.js';
|
||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers.js';
|
||||
import { assertUserIsTabletopOwner } from './shared/tabletopPermissions.js';
|
||||
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||
import Tabletops from '../Tabletops';
|
||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions';
|
||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers';
|
||||
import { assertUserIsTabletopOwner } from './shared/tabletopPermissions';
|
||||
import Creatures from '/imports/api/creature/creatures/Creatures';
|
||||
|
||||
const removeTabletop = new ValidatedMethod({
|
||||
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import Tabletops from '../../Tabletops.js';
|
||||
import Tabletops from '../../Tabletops';
|
||||
|
||||
export function assertUserInTabletop(tabletopId, userId){
|
||||
export function assertUserInTabletop(tabletopId, userId) {
|
||||
let tabletop = Tabletops.findOne(tabletopId);
|
||||
if (!tabletop){
|
||||
if (!tabletop) {
|
||||
throw new Meteor.Error('Tabletop does not exist',
|
||||
'No tabletop could be found for the given tabletop id');
|
||||
'No tabletop could be found for the given tabletop id');
|
||||
}
|
||||
if (tabletop.gameMaster !== userId && !tabletop.players.includes(userId)){
|
||||
if (tabletop.gameMaster !== userId && !tabletop.players.includes(userId)) {
|
||||
throw new Meteor.Error('Not in tabletop',
|
||||
'The user is not the gamemaster or a player in the given tabletop');
|
||||
'The user is not the gamemaster or a player in the given tabletop');
|
||||
}
|
||||
}
|
||||
|
||||
export function assertUserIsTabletopOwner(tabletopId, userId){
|
||||
export function assertUserIsTabletopOwner(tabletopId, userId) {
|
||||
let tabletop = Tabletops.findOne(tabletopId);
|
||||
if (!tabletop){
|
||||
if (!tabletop) {
|
||||
throw new Meteor.Error('Tabletop does not exist',
|
||||
'No tabletop could be found for the given tabletop id');
|
||||
'No tabletop could be found for the given tabletop id');
|
||||
}
|
||||
if (tabletop.gameMaster !== userId){
|
||||
if (tabletop.gameMaster !== userId) {
|
||||
throw new Meteor.Error('Not the owner',
|
||||
'The user is not the owner of the given tabletop');
|
||||
'The user is not the owner of the given tabletop');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user