send pgp onboarding email to user on 2nd day

This commit is contained in:
Son NK 2020-03-24 21:01:38 +01:00
parent 929e965f23
commit c02b8298fc
5 changed files with 103 additions and 13 deletions

View file

@ -194,6 +194,7 @@ FLASK_PROFILER_PASSWORD = os.environ.get("FLASK_PROFILER_PASSWORD")
# Job names
JOB_ONBOARDING_1 = "onboarding-1"
JOB_ONBOARDING_2 = "onboarding-2"
# for pagination
PAGE_LIMIT = 20

View file

@ -17,6 +17,7 @@ from app.config import (
URL,
AVATAR_URL_EXPIRATION,
JOB_ONBOARDING_1,
JOB_ONBOARDING_2,
)
from app.extensions import db
from app.log import LOG
@ -169,6 +170,11 @@ class User(db.Model, ModelMixin, UserMixin):
payload={"user_id": user.id},
run_at=arrow.now().shift(days=1),
)
Job.create(
name=JOB_ONBOARDING_2,
payload={"user_id": user.id},
run_at=arrow.now().shift(days=2),
)
db.session.flush()
return user

View file

@ -6,7 +6,7 @@ import time
import arrow
from app.config import JOB_ONBOARDING_1
from app.config import JOB_ONBOARDING_1, JOB_ONBOARDING_2
from app.email_utils import send_email, render
from app.extensions import db
from app.log import LOG
@ -30,15 +30,7 @@ def new_app():
return app
def onboarding_1(user):
if not user.activated:
LOG.d("User %s is not activated", user)
return
if not user.notification:
LOG.d("User %s disable notification setting", user)
return
def onboarding_send_from_alias(user):
send_email(
user.email,
f"Do you know you can send emails to anyone from your alias?",
@ -47,6 +39,15 @@ def onboarding_1(user):
)
def onboarding_pgp(user):
send_email(
user.email,
f"Do you know you can encrypt your emails so only you can read them",
render("com/onboarding/pgp.txt", user=user),
render("com/onboarding/pgp.html", user=user),
)
if __name__ == "__main__":
while True:
# run a job 1h earlier or later is not a big deal ...
@ -70,9 +71,19 @@ if __name__ == "__main__":
user = User.get(user_id)
# user might delete their account in the meantime
if user:
LOG.d("run onboarding_1 for user %s", user)
onboarding_1(user)
# or disable the notification
if user and user.notification and user.activated:
LOG.d("send onboarding send-from-alias email to user %s", user)
onboarding_send_from_alias(user)
elif job.name == JOB_ONBOARDING_2:
user_id = job.payload.get("user_id")
user = User.get(user_id)
# user might delete their account in the meantime
# or disable the notification
if user and user.notification and user.activated:
LOG.d("send onboarding pgp email to user %s", user)
onboarding_pgp(user)
else:
LOG.error("Unknown job name %s", job.name)

View file

@ -0,0 +1,40 @@
{% extends "base.html" %}
{% block content %}
{{ render_text("Hi " + user.name) }}
{{ render_text("If you happen to use Gmail, Yahoo, Outlook, etc, do you know these services can read your emails?") }}
{{ render_text("If you want to keep your emails only readable by you, Pretty Good Privacy (PGP) is maybe the solution.") }}
{{ render_text('Highly recommended, open source and free, PGP is unfortunately not widely supported. However with SimpleLogin most recent PGP support, you can now enable PGP on emails sent to your aliases easily.') }}
{{ render_text('Without PGP the emails sent to an alias are forwarded by SimpleLogin as-is to your mailbox, leaving anyone in-between or your email service able to read your emails:') }}
<img src="https://simplelogin.io/blog/without-pgp.png" alt="Without PGP" style="max-width: 100%">
{{ render_text("With PGP enabled, all emails arrived at SimpleLogin are encrypted with your public key before being forwarded to your mailbox:") }}
<img src="https://simplelogin.io/blog/with-pgp.png" alt="Without PGP" style="max-width: 100%">
{{ render_text("You can find more info on our announcement post on https://simplelogin.io/blog/introducing-pgp/") }}
{{ render_text("You can create and manage your PGP keys when adding or editing your mailboxes. Check it out on your mailbox dashboard.") }}
{{ render_button("Add your PGP key", "https://app.simplelogin.io/dashboard/mailbox") }}
{{ render_text("Our next important feature is the coming of an iOS app. If you use iPhone or iPad want to help us testing out the app, please reply to this email so we can add you into the TestFlight program.
") }}
{{ render_text("For Android users, don't worry: the Android version is already in progress.
") }}
{{ render_text('Thanks, <br />SimpleLogin Team.') }}
{{ render_text('<strong>P.S.</strong> Need immediate help getting started? Just reply to this email, the SimpleLogin support team is always ready to help!.') }}
{% endblock %}
{% block footer %}
This email is sent to {{ user.email }} and is part of our onboarding series. Unsubscribe on
<a href="https://app.simplelogin.io/dashboard/setting#notification">Settings</a>
{% endblock %}

View file

@ -0,0 +1,32 @@
This email is sent to {{ user.email }} and is part of our onboarding series.
Unsubscribe from our emails on https://app.simplelogin.io/dashboard/setting#notification
----------------
Hi {{user.name}}
If you happen to use Gmail, Yahoo, Outlook, etc, do you know these services can read your emails?
If you want to keep your emails only readable by you, Pretty Good Privacy (PGP) is maybe the solution.
Highly recommended, open source and free, PGP is unfortunately not widely supported. However with SimpleLogin most recent PGP support, you can now enable PGP on emails sent to your aliases easily.
Without PGP the emails sent to an alias are forwarded by SimpleLogin as-is to your mailbox, leaving anyone in-between or your email service able to read your emails:
https://simplelogin.io/blog/without-pgp.png
With PGP enabled, all emails arrived at SimpleLogin are encrypted with your public key before being forwarded to your mailbox:
https://simplelogin.io/blog/with-pgp.png
You can find more info on our announcement post on https://simplelogin.io/blog/introducing-pgp/
You can create and manage your PGP keys when adding or editing your mailboxes. Check it out on your mailbox dashboard at https://app.simplelogin.io/dashboard/mailbox
Our next important feature is the coming of an iOS app. If you use iPhone or iPad want to help us testing out the app, please reply to this email so we can add you into the TestFlight program.
For Android users, don't worry: the Android version is already in progress.
As usual, let us know if you have any question by replying to this email.
Best regards,
SimpleLogin team.