import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';

import { dbArena } from '/db/dbArena';
import { dbArenaFighters } from '/db/dbArenaFighters';
import { limitSubscription } from '/server/imports/utils/rateLimit';
import { debug } from '/server/imports/utils/debug';

Meteor.publish('arenaInfo', function(arenaId) {
  debug.log('publish arenaInfo', arenaId);
  check(arenaId, String);
  const disableOplog = true;

  return [
    dbArena.find(arenaId, { disableOplog }),
    dbArenaFighters.find({ arenaId }, { fields: { investors: 0 } }, { disableOplog })
  ];
});
// 一分鐘最多20次
limitSubscription('arenaInfo');

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';

import { dbArena } from '/db/dbArena';
import { dbArenaFighters } from '/db/dbArenaFighters';
import { limitSubscription } from '/server/imports/utils/rateLimit';
import { debug } from '/server/imports/utils/debug';

Meteor.publish('arenaInfo', function(arenaId) {
  debug.log('publish arenaInfo', arenaId);
  check(arenaId, String);
  const disableOplog = true;

  return [
    dbArena.find(arenaId, { disableOplog }),
    dbArenaFighters.find({ arenaId }, {
      fields: {
        investors: 0,
        attackSequence: 0
      }
    }, { disableOplog })
  ];
});
// 一分鐘最多20次
limitSubscription('arenaInfo');

修正亂鬥攻擊順序經由 ``arenaInfo`` leak 的問題