|
|
|
|
|
by hackthemack
241 days ago
|
|
I guess I just never encounter code like this in the big enterprise code bases I have had to weed through. Question. If you want to do one email for expired users and another for non expired users and another email for users that somehow have a date problem in their data.... Do you just do the const emails = three different times? In my coding world it looks a lot like doing a
SELECT * ON users WHERE isExpired < Date.now but in some cases you just grab it all, loop through it all, and do little switches to do different things based on different isExpired. |
|
But perhaps you can write a more generic function like generateExpiryEmailOrWhatever that understands the user object and contains the logic for what type of email to draft. It might need to output some flag if, for a particular user, there is no need to send an email. Then you could add a filter before the final (send) step.