Remind user that their manual sub is ending soon.
This commit is contained in:
parent
fb62322794
commit
c1bd2f83e3
|
@ -755,6 +755,8 @@ class ManualSubscription(db.Model, ModelMixin):
|
||||||
# for storing note about this subscription
|
# for storing note about this subscription
|
||||||
comment = db.Column(db.Text, nullable=True)
|
comment = db.Column(db.Text, nullable=True)
|
||||||
|
|
||||||
|
user = db.relationship(User)
|
||||||
|
|
||||||
|
|
||||||
class DeletedAlias(db.Model, ModelMixin):
|
class DeletedAlias(db.Model, ModelMixin):
|
||||||
"""Store all deleted alias to make sure they are NOT reused"""
|
"""Store all deleted alias to make sure they are NOT reused"""
|
||||||
|
|
37
cron.py
37
cron.py
|
@ -3,7 +3,7 @@ import argparse
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
from app.config import IGNORED_EMAILS, ADMIN_EMAIL
|
from app.config import IGNORED_EMAILS, ADMIN_EMAIL
|
||||||
from app.email_utils import send_email, send_trial_end_soon_email
|
from app.email_utils import send_email, send_trial_end_soon_email, render
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import (
|
from app.models import (
|
||||||
|
@ -14,6 +14,7 @@ from app.models import (
|
||||||
ForwardEmail,
|
ForwardEmail,
|
||||||
CustomDomain,
|
CustomDomain,
|
||||||
Client,
|
Client,
|
||||||
|
ManualSubscription,
|
||||||
)
|
)
|
||||||
from server import create_app
|
from server import create_app
|
||||||
|
|
||||||
|
@ -29,6 +30,35 @@ def notify_trial_end():
|
||||||
send_trial_end_soon_email(user)
|
send_trial_end_soon_email(user)
|
||||||
|
|
||||||
|
|
||||||
|
def notify_manual_sub_end():
|
||||||
|
for manual_sub in ManualSubscription.query.all():
|
||||||
|
need_reminder = False
|
||||||
|
if arrow.now().shift(days=14) > manual_sub.end_at > arrow.now().shift(days=13):
|
||||||
|
need_reminder = True
|
||||||
|
elif arrow.now().shift(days=4) > manual_sub.end_at > arrow.now().shift(days=3):
|
||||||
|
need_reminder = True
|
||||||
|
|
||||||
|
if need_reminder:
|
||||||
|
user = manual_sub.user
|
||||||
|
LOG.debug("Remind user %s that their manual sub is ending soon", user)
|
||||||
|
send_email(
|
||||||
|
user.email,
|
||||||
|
f"Your trial will end soon {user.name}",
|
||||||
|
render(
|
||||||
|
"transactional/manual-subscription-end.txt",
|
||||||
|
name=user.name,
|
||||||
|
user=user,
|
||||||
|
manual_sub=manual_sub,
|
||||||
|
),
|
||||||
|
render(
|
||||||
|
"transactional/manual-subscription-end.html",
|
||||||
|
name=user.name,
|
||||||
|
user=user,
|
||||||
|
manual_sub=manual_sub,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def stats():
|
def stats():
|
||||||
"""send admin stats everyday"""
|
"""send admin stats everyday"""
|
||||||
if not ADMIN_EMAIL:
|
if not ADMIN_EMAIL:
|
||||||
|
@ -118,7 +148,7 @@ if __name__ == "__main__":
|
||||||
"--job",
|
"--job",
|
||||||
help="Choose a cron job to run",
|
help="Choose a cron job to run",
|
||||||
type=str,
|
type=str,
|
||||||
choices=["stats", "notify_trial_end",],
|
choices=["stats", "notify_trial_end", "notify_manual_subscription_end"],
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -131,3 +161,6 @@ if __name__ == "__main__":
|
||||||
elif args.job == "notify_trial_end":
|
elif args.job == "notify_trial_end":
|
||||||
LOG.d("Notify users with trial ending soon")
|
LOG.d("Notify users with trial ending soon")
|
||||||
notify_trial_end()
|
notify_trial_end()
|
||||||
|
elif args.job == "notify_manual_subscription_end":
|
||||||
|
LOG.d("Notify users with manual subscription ending soon")
|
||||||
|
notify_manual_sub_end()
|
||||||
|
|
|
@ -10,3 +10,9 @@ jobs:
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
schedule: "0 8 * * *"
|
schedule: "0 8 * * *"
|
||||||
captureStderr: true
|
captureStderr: true
|
||||||
|
|
||||||
|
- name: SimpleLogin Notify Manual Subscription Ends
|
||||||
|
command: python /code/cron.py -j notify_manual_subscription_end
|
||||||
|
shell: /bin/bash
|
||||||
|
schedule: "0 9 * * *"
|
||||||
|
captureStderr: true
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if name %}
|
||||||
|
{{ render_text("Hi " + name + ",") }}
|
||||||
|
{% else %}
|
||||||
|
{{ render_text("Hi,") }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ render_text("Your subscription will end " + manual_sub.end_at.humanize() + ".") }}
|
||||||
|
|
||||||
|
{{ render_text("When the subscription ends:") }}
|
||||||
|
|
||||||
|
{{ render_text("- All aliases/domains/directories you have created are <b>kept</b> and continue working normally.") }}
|
||||||
|
{{ render_text("- You cannot create new aliases if you exceed the free plan limit, i.e. have more than 5 aliases.") }}
|
||||||
|
{{ render_text("- As features like <b>catch-all</b> or <b>directory</b> allow you to create aliases on-the-fly, those aliases cannot be automatically created if you have more than 5 aliases.") }}
|
||||||
|
{{ render_text("- You cannot add new domain or directory.") }}
|
||||||
|
|
||||||
|
{{ render_text('You can upgrade today to continue using all these Premium features (and much more coming).') }}
|
||||||
|
|
||||||
|
{{ render_text('Thanks, <br />SimpleLogin Team.') }}
|
||||||
|
{{ render_text('P.S. If you have any questions or need any help, please don\'t hesitate to reach out. You can simply reply to this email or reach us via Twitter/Github.') }}
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
Hi {{name}}
|
||||||
|
|
||||||
|
Your subscription will end {{ manual_sub.end_at.humanize() }}.
|
||||||
|
|
||||||
|
When the subscription ends:
|
||||||
|
|
||||||
|
- All aliases/domains/directories you have created are kept and continue working.
|
||||||
|
- You cannot create new aliases if you exceed the free plan limit, i.e. have more than 5 aliases.
|
||||||
|
- As features like "catch-all" or "directory" allow you to create aliases on-the-fly, those aliases cannot be automatically created if you have more than 5 aliases.
|
||||||
|
- You cannot add new domain or directory.
|
||||||
|
|
||||||
|
You can upgrade today to continue using all these Premium features (and much more coming).
|
||||||
|
|
||||||
|
Best,
|
||||||
|
Son - SimpleLogin founder.
|
Loading…
Reference in New Issue