[https://github.com/HabitRPG/habitrpg/issues/1057] don't exit-early when
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:
Vendored
-5
@@ -9172,11 +9172,6 @@ var global=self;/**
|
|||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
_ref1 = [options.paths || {}, +options.now || +(new Date)], paths = _ref1[0], now = _ref1[1];
|
_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({
|
daysMissed = helpers.daysSince(user.lastCron, _.defaults({
|
||||||
now: now
|
now: now
|
||||||
}, user.preferences));
|
}, user.preferences));
|
||||||
|
|||||||
+8
-5
@@ -361,11 +361,14 @@ updateStats = (user, newStats, options={}) ->
|
|||||||
obj.cron = (user, options={}) ->
|
obj.cron = (user, options={}) ->
|
||||||
[paths, now] = [options.paths || {}, +options.now || +new Date]
|
[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
|
# They went to a different timezone
|
||||||
# FIXME move this to pre-save in mongoose
|
# FIXME:
|
||||||
if !user.lastCron? or user.lastCron is 'new' or moment(user.lastCron).isAfter(now)
|
# (1) This exit-early code isn't taking timezone into consideration!!
|
||||||
user.lastCron = now; paths['lastCron'] = true
|
# (2) Won't switching timezones be handled automatically client-side anyway? (aka, can we just remove this code?)
|
||||||
return
|
# (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)
|
daysMissed = helpers.daysSince user.lastCron, _.defaults({now}, user.preferences)
|
||||||
return unless daysMissed > 0
|
return unless daysMissed > 0
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ module.exports =
|
|||||||
|
|
||||||
preferences: { gender: 'm', skin: 'white', hair: 'blond', armorSet: 'v1', dayStart:0, showHelm: true }
|
preferences: { gender: 'm', skin: 'white', hair: 'blond', armorSet: 'v1', dayStart:0, showHelm: true }
|
||||||
apiToken: uuid() # set in newUserObject below
|
apiToken: uuid() # set in newUserObject below
|
||||||
lastCron: +new Date #this will be replaced with `+new Date` on first run
|
lastCron: +new Date
|
||||||
balance: 0
|
balance: 0
|
||||||
flags:
|
flags:
|
||||||
partyEnabled: false
|
partyEnabled: false
|
||||||
|
|||||||
Reference in New Issue
Block a user