Refactored actions, 'cast a spell' task now works

This commit is contained in:
Thaum Rystra
2024-10-28 12:28:36 +02:00
parent 804c5f3aee
commit 8f8c9c28aa
39 changed files with 423 additions and 399 deletions

View File

@@ -2,6 +2,7 @@ import { ValidatedMethod } from 'meteor/mdg:validated-method';
import EngineActions from '/imports/api/engine/action/EngineActions';
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions';
import { getCreature } from '/imports/api/engine/loadCreatures';
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
export const updateAction = new ValidatedMethod({
name: 'actions.updateAction',
@@ -11,6 +12,11 @@ export const updateAction = new ValidatedMethod({
if (path !== 'targetIds') throw new Meteor.Error('Can only update target ids');
if (!Array.isArray(value)) throw new Meteor.Error('TargetIds must be an array');
},
mixins: [RateLimiterMixin],
rateLimit: {
numRequests: 10,
timeInterval: 5000,
},
run: async function ({ _id, path, value }: { _id: string, path: 'targetIds', value: string[] }) {
const action = await EngineActions.findOneAsync(_id);
if (!action) {