I am making a very enrollment based service, where accounts are “invitation only”. Luckily, Meteor makes this very easy. The problem I am having is updating status.
I have 4 statuses:
User profile is created (‘new’)
User has been invited (‘invited’)
User has accepted the invitation (‘enrolled’)
User has declined the invitation, deactivated their account, or their email token has expired (‘unenrolled’)
The problem I am having is the unenrolled status, particularly, when their token has expired. On invitation, I do the following:
Now the problem I am having is setting some sort of event when their token expires to set their enrollment status differently in some sort of efficient manner. I was thinking of adding some sort of pre-find hook, but it seems excessive work to do that on every find.
Ideally, I’d like to schedule an event for expiresAt to update the status to unenrolled. Is this possible?
You could set up an hourly running task that checks for expiresAt dates in the past and have not yet been processed, processes them, and ticks a mark somewhere indicating that they have. Percolate:syncedcron is very straightforward for such tasks.
Since this is the top Google result for “meteor scheduler” and SyncedCron is deprecated, I thought I’d mention that the new Steve Jobs package is designed just for Meteor and supports this kind of use case (and others too)
Thanks man! IIRC, it will add one month using the standard operations available on the JavaScript Date object. IIRC, if that ends up setting something like February 30, it will be adjusted to February 27 or 28.
Awesome. I’ll continue with more tests and will report anything wonky, though given the quality of your packages I suspect I won’t need to report anything.