Merge pull request #82 from simple-login/fix-trial-end-email

only send trial-end email to user who is in trial
This commit is contained in:
Son Nguyen Kim 2020-02-15 16:53:31 +07:00 committed by GitHub
commit 100305c4bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)