mirror of
https://github.com/simple-login/app.git
synced 2025-10-06 05:17:41 +08:00
WIP send user onboarding email 1day after the account creation
This commit is contained in:
parent
61229200a5
commit
0f4e803639
3 changed files with 18 additions and 4 deletions
|
@ -10,7 +10,13 @@ from sqlalchemy import text, desc
|
||||||
from sqlalchemy_utils import ArrowType
|
from sqlalchemy_utils import ArrowType
|
||||||
|
|
||||||
from app import s3
|
from app import s3
|
||||||
from app.config import EMAIL_DOMAIN, MAX_NB_EMAIL_FREE_PLAN, URL, AVATAR_URL_EXPIRATION
|
from app.config import (
|
||||||
|
EMAIL_DOMAIN,
|
||||||
|
MAX_NB_EMAIL_FREE_PLAN,
|
||||||
|
URL,
|
||||||
|
AVATAR_URL_EXPIRATION,
|
||||||
|
JOB_ONBOARDING_1,
|
||||||
|
)
|
||||||
from app.email_utils import get_email_name
|
from app.email_utils import get_email_name
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
|
@ -144,6 +150,14 @@ class User(db.Model, ModelMixin, UserMixin):
|
||||||
GenEmail.create_new(user.id, prefix="my-first-alias")
|
GenEmail.create_new(user.id, prefix="my-first-alias")
|
||||||
db.session.flush()
|
db.session.flush()
|
||||||
|
|
||||||
|
# Schedule onboarding emails
|
||||||
|
Job.create(
|
||||||
|
name=JOB_ONBOARDING_1,
|
||||||
|
payload={"user_id": user.id},
|
||||||
|
run_at=arrow.now().shift(days=1),
|
||||||
|
)
|
||||||
|
db.session.flush()
|
||||||
|
|
||||||
return user
|
return user
|
||||||
|
|
||||||
def lifetime_or_active_subscription(self) -> bool:
|
def lifetime_or_active_subscription(self) -> bool:
|
||||||
|
|
2
cron.py
2
cron.py
|
@ -122,6 +122,8 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
if args.job == "stats":
|
if args.job == "stats":
|
||||||
|
LOG.d("Compute stats")
|
||||||
stats()
|
stats()
|
||||||
elif args.job == "notify_trial_end":
|
elif args.job == "notify_trial_end":
|
||||||
|
LOG.d("Notify users with trial ending soon")
|
||||||
notify_trial_end()
|
notify_trial_end()
|
||||||
|
|
|
@ -6,9 +6,7 @@ import time
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
from app.config import (
|
from app.config import JOB_ONBOARDING_1
|
||||||
JOB_ONBOARDING_1,
|
|
||||||
)
|
|
||||||
from app.email_utils import (
|
from app.email_utils import (
|
||||||
send_email,
|
send_email,
|
||||||
render,
|
render,
|
||||||
|
|
Loading…
Add table
Reference in a new issue