only send trial-end email to user who is in trial

i.e. users who:
1. has lifetime licence or active subscription and
2. is in trial period
This commit is contained in:
Son NK 2020-02-15 16:29:44 +07:00
parent 83c2bb2b23
commit 4ad44dbcdf
1 changed files with 3 additions and 1 deletions

View File

@ -22,7 +22,9 @@ def notify_trial_end():
for user in User.query.filter(
User.activated == True, User.trial_end.isnot(None), User.lifetime == False
).all():
if arrow.now().shift(days=3) > user.trial_end >= arrow.now().shift(days=2):
if user.in_trial() and arrow.now().shift(
days=3
) > user.trial_end >= arrow.now().shift(days=2):
LOG.d("Send trial end email to user %s", user)
send_trial_end_soon_email(user)