handle case user has taken a paid subscription in notify_manual_sub_end()
This commit is contained in:
parent
c0aa45fc6d
commit
e62c5d1591
21
cron.py
21
cron.py
|
@ -147,6 +147,7 @@ def notify_premium_end():
|
||||||
|
|
||||||
def notify_manual_sub_end():
|
def notify_manual_sub_end():
|
||||||
for manual_sub in ManualSubscription.all():
|
for manual_sub in ManualSubscription.all():
|
||||||
|
manual_sub: ManualSubscription
|
||||||
need_reminder = False
|
need_reminder = False
|
||||||
if arrow.now().shift(days=14) > manual_sub.end_at > arrow.now().shift(days=13):
|
if arrow.now().shift(days=14) > manual_sub.end_at > arrow.now().shift(days=13):
|
||||||
need_reminder = True
|
need_reminder = True
|
||||||
|
@ -155,6 +156,26 @@ def notify_manual_sub_end():
|
||||||
|
|
||||||
if need_reminder:
|
if need_reminder:
|
||||||
user = manual_sub.user
|
user = manual_sub.user
|
||||||
|
|
||||||
|
# user can have a (free) manual subscription but has taken a paid subscription via
|
||||||
|
# Paddle, Coinbase or Apple since then
|
||||||
|
if manual_sub.is_giveaway:
|
||||||
|
if user.get_subscription():
|
||||||
|
LOG.d("%s has a active Paddle subscription", user)
|
||||||
|
continue
|
||||||
|
|
||||||
|
coinbase_subscription: CoinbaseSubscription = (
|
||||||
|
CoinbaseSubscription.get_by(user_id=user.id)
|
||||||
|
)
|
||||||
|
if coinbase_subscription and coinbase_subscription.is_active():
|
||||||
|
LOG.d("%s has a active Coinbase subscription", user)
|
||||||
|
continue
|
||||||
|
|
||||||
|
apple_sub: AppleSubscription = AppleSubscription.get_by(user_id=user.id)
|
||||||
|
if apple_sub and apple_sub.is_valid():
|
||||||
|
LOG.d("%s has a active Apple subscription", user)
|
||||||
|
continue
|
||||||
|
|
||||||
LOG.d("Remind user %s that their manual sub is ending soon", user)
|
LOG.d("Remind user %s that their manual sub is ending soon", user)
|
||||||
send_email(
|
send_email(
|
||||||
user.email,
|
user.email,
|
||||||
|
|
Loading…
Reference in New Issue