From 161069cfec44c5ce44a9ee20050eb60d75f2688f Mon Sep 17 00:00:00 2001 From: Alys Date: Sat, 31 Oct 2015 04:12:43 +1000 Subject: [PATCH] prevent cron running if the lastCron date is in the future --- common/script/index.coffee | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/common/script/index.coffee b/common/script/index.coffee index 473167bc2e..b2be7f5282 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -1697,14 +1697,10 @@ api.wrap = (user, main=true) -> cron: (options={}) -> now = +options.now || +new Date - # 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 + if moment(user.lastCron).isAfter(now) + # This might not be taking timezone into consideration. + user.lastCron = now + return daysMissed = api.daysSince user.lastCron, _.defaults({now}, user.preferences) return unless daysMissed > 0