cb42a31c43
* start upgrade to node 8 * upgrade travis * improve travis * Remove bluebird, babel (except for modules) from server (WIP) (#9947) * remove bluebird, babel from server (except for modules) * fixes * fix path * fix path * fix export * fix export * fix test * fix tests * remove plugin for transform-object-rest-spread since it is supported in node8 * babel: correct syntax rest spread * remove bluebird * update migrations archive readme * fix package-lock.json * fix typo * add package-loc
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
/* let migrationName = 'Jackalopes for Unlimited Subscribers'; */
|
|
|
|
/*
|
|
* This migration will find users with unlimited subscriptions who are also eligible for Jackalope mounts, and award them
|
|
*/
|
|
|
|
import { model as Group } from '../../website/server/models/group';
|
|
import { model as User } from '../../website/server/models/user';
|
|
|
|
async function handOutJackalopes () {
|
|
let promises = [];
|
|
let cursor = User.find({
|
|
'purchased.plan.customerId': 'habitrpg',
|
|
}).cursor();
|
|
|
|
cursor.on('data', async (user) => {
|
|
console.log(`User: ${ user._id}`);
|
|
|
|
let groupList = [];
|
|
if (user.party._id) groupList.push(user.party._id);
|
|
groupList = groupList.concat(user.guilds);
|
|
|
|
let subscribedGroup =
|
|
await Group.findOne({
|
|
_id: {$in: groupList},
|
|
'purchased.plan.planId': 'group_monthly',
|
|
'purchased.plan.dateTerminated': null,
|
|
},
|
|
{_id: 1}
|
|
);
|
|
|
|
if (subscribedGroup) {
|
|
User.update({_id: user._id}, {$set: {'items.mounts.Jackalope-RoyalPurple': true}}).exec();
|
|
promises.push(user.save());
|
|
}
|
|
});
|
|
|
|
cursor.on('close', async () => {
|
|
console.log('done');
|
|
return await Promise.all(promises);
|
|
});
|
|
}
|
|
|
|
module.exports = handOutJackalopes;
|