attempting to detect if they've switched timezones. Also, don't need to
sanitize user.lastCron in shared, do it in Mongoose
This commit is contained in:
Tyler Renelle
2013-11-29 17:15:41 -07:00
parent bf7f7b6583
commit 282e105ea3
3 changed files with 9 additions and 11 deletions

View File

@@ -9172,11 +9172,6 @@ var global=self;/**
options = {};
}
_ref1 = [options.paths || {}, +options.now || +(new Date)], paths = _ref1[0], now = _ref1[1];
if ((user.lastCron == null) || user.lastCron === 'new' || moment(user.lastCron).isAfter(now)) {
user.lastCron = now;
paths['lastCron'] = true;
return;
}
daysMissed = helpers.daysSince(user.lastCron, _.defaults({
now: now
}, user.preferences));

View File

@@ -361,11 +361,14 @@ updateStats = (user, newStats, options={}) ->
obj.cron = (user, options={}) ->
[paths, now] = [options.paths || {}, +options.now || +new Date]
# New user (!lastCron, lastCron==new) or it got busted somehow, maybe they went to a different timezone
# FIXME move this to pre-save in mongoose
if !user.lastCron? or user.lastCron is 'new' or moment(user.lastCron).isAfter(now)
user.lastCron = now; paths['lastCron'] = true
return
# They went to a different timezone
# FIXME:
# (1) This exit-early code isn't taking timezone into consideration!!
# (2) Won't switching timezones be handled automatically client-side anyway? (aka, can we just remove this code?)
# (3) And if not, is this the correct way to handle switching timezones
# if moment(user.lastCron).isAfter(now)
# user.lastCron = now
# return
daysMissed = helpers.daysSince user.lastCron, _.defaults({now}, user.preferences)
return unless daysMissed > 0

View File

@@ -105,7 +105,7 @@ module.exports =
preferences: { gender: 'm', skin: 'white', hair: 'blond', armorSet: 'v1', dayStart:0, showHelm: true }
apiToken: uuid() # set in newUserObject below
lastCron: +new Date #this will be replaced with `+new Date` on first run
lastCron: +new Date
balance: 0
flags:
partyEnabled: false