set purchased.plan.dateUpdated during cron if it hasn't been set - ref https://github.com/HabitRPG/habitrpg/issues/6682

This commit is contained in:
Alys
2016-02-09 20:51:32 +10:00
parent 13c06756e3
commit e7c88d6e5d

View File

@@ -2415,6 +2415,10 @@ api.wrap = function(user, main) {
};
plan = (ref = user.purchased) != null ? ref.plan : void 0;
if (plan != null ? plan.customerId : void 0) {
if (typeof plan.dateUpdated === "undefined") {
// partial compensation for bug in subscription creation - https://github.com/HabitRPG/habitrpg/issues/6682
plan.dateUpdated = new Date();
}
if (moment(plan.dateUpdated).format('MMYYYY') !== moment().format('MMYYYY')) {
plan.gemsBought = 0;
plan.dateUpdated = new Date();