mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-30 04:32:45 +01:00
[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:
5
dist/habitrpg-shared.js
vendored
5
dist/habitrpg-shared.js
vendored
@@ -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));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user