Send welcome mail to proton created users (#1099)
* Send welcome mail to proton created users * Skip import * Use new logo Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
fb1e14e509
commit
fbb59a1531
|
@ -267,6 +267,7 @@ JOB_DELETE_ACCOUNT = "delete-account"
|
|||
JOB_DELETE_MAILBOX = "delete-mailbox"
|
||||
JOB_DELETE_DOMAIN = "delete-domain"
|
||||
JOB_SEND_USER_REPORT = "send-user-report"
|
||||
JOB_SEND_PROTON_WELCOME_1 = "proton-welcome-1"
|
||||
|
||||
# for pagination
|
||||
PAGE_LIMIT = 20
|
||||
|
|
|
@ -44,6 +44,7 @@ from app.config import (
|
|||
ROOT_DIR,
|
||||
NOREPLY,
|
||||
PARTNER_API_TOKEN_SECRET,
|
||||
JOB_SEND_PROTON_WELCOME_1,
|
||||
)
|
||||
from app.db import Session
|
||||
from app.errors import (
|
||||
|
@ -564,6 +565,11 @@ class User(Base, ModelMixin, UserMixin, PasswordOracle):
|
|||
user.flags = User.FLAG_CREATED_FROM_PARTNER
|
||||
user.notification = False
|
||||
user.trial_end = None
|
||||
Job.create(
|
||||
name=JOB_SEND_PROTON_WELCOME_1,
|
||||
payload={"user_id": user.id},
|
||||
run_at=arrow.now(),
|
||||
)
|
||||
Session.flush()
|
||||
return user
|
||||
|
||||
|
|
|
@ -87,6 +87,25 @@ def onboarding_mailbox(user):
|
|||
)
|
||||
|
||||
|
||||
def welcome_proton(user):
|
||||
to_email, _, _ = user.get_communication_email()
|
||||
if not to_email:
|
||||
return
|
||||
|
||||
send_email(
|
||||
to_email,
|
||||
"Welcome to SimpleLogin, an email masking service provided by Proton",
|
||||
render(
|
||||
"com/onboarding/welcome-proton-user.txt.jinja2",
|
||||
user=user,
|
||||
to_email=to_email,
|
||||
),
|
||||
render("com/onboarding/welcome-proton-user.html", user=user, to_email=to_email),
|
||||
retries=3,
|
||||
ignore_smtp_error=True,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
while True:
|
||||
# wrap in an app context to benefit from app setup like database cleanup, sentry integration, etc
|
||||
|
@ -207,6 +226,12 @@ SimpleLogin team.
|
|||
export_job = ExportUserDataJob.create_from_job(job)
|
||||
if export_job:
|
||||
export_job.run()
|
||||
elif job.name == config.JOB_SEND_PROTON_WELCOME_1:
|
||||
user_id = job.payload.get("user_id")
|
||||
user = User.get(user_id)
|
||||
if user and user.activated:
|
||||
LOG.d("send proton welcome email to user %s", user)
|
||||
welcome_proton(user)
|
||||
else:
|
||||
LOG.e("Unknown job name %s", job.name)
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 29 KiB |
|
@ -449,7 +449,7 @@
|
|||
<tr>
|
||||
<td class="email-masthead" style="word-break: break-word; font-family: Helvetica, Arial, sans-serif; font-size: 16px; text-align: center; padding: 25px 0;" align="center">
|
||||
<a href="{{LANDING_PAGE_URL}}" class="f-fallback email-masthead_name" style="color: #A8AAAF; font-size: 16px; font-weight: bold; text-decoration: none; text-shadow: 0 1px 0 white;">
|
||||
<img src="{{URL}}/static/logo.png" style="width: 150px; margin: auto">
|
||||
{% block logo %}<img src="{{URL}}/static/logo.png" style="width: 150px; margin: auto">{% endblock %}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
|
||||
{% block logo %}<img src="{{URL}}/static/logo-sl-proton.svg" style="width: 150px; margin: auto">{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% call text() %}
|
||||
Welcome to SimpleLogin, a service developed by Proton to protect your email address!
|
||||
{% endcall %}
|
||||
|
||||
{% call text() %}
|
||||
This is the first email you receive via your first alias {{ to_address }}
|
||||
{% endcall %}
|
||||
|
||||
{% call text() %}
|
||||
This alias was automatically created the first time you accessed SimpleLogin.
|
||||
Emails sent to it are forwarded to your Proton mailbox.
|
||||
If you want to reply to an email, just hit "Reply" and the response will come from this alias.
|
||||
Your personal email address will stay hidden.
|
||||
{% endcall %}
|
||||
|
||||
{% call text() %}
|
||||
SimpleLogin is also available on <a href="https://play.google.com/store/apps/details?id=io.simplelogin.android">Android</a>
|
||||
and <a href="https://apps.apple.com/app/id1494359858">iOS</a> so you can manage your aliases on the go.
|
||||
{% endcall %}
|
||||
|
||||
{% call text() %}
|
||||
For any question, feedback or feature request, please join our <a href="https://github.com/simple-login/app/discussions">GitHub forum</a>.
|
||||
You can also join our <a href="https://www.reddit.com/r/Simplelogin/">Reddit</a> or follow our <a href="https://twitter.com/simple_login">Twitter</a>.
|
||||
{% endcall %}
|
||||
|
||||
{% call text() %}
|
||||
Best, <br/>
|
||||
SimpleLogin Team.
|
||||
{% endcall %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Welcome to SimpleLogin, a service developed by Proton to protect your email address!
|
||||
|
||||
This is the first email you receive via your first alias {{ to_address }}
|
||||
|
||||
This alias was automatically created the first time you accessed SimpleLogin.
|
||||
Emails sent to it are forwarded to your Proton mailbox.
|
||||
If you want to reply to an email, just hit "Reply" and the response will come from this alias.
|
||||
Your personal email address will stay hidden.
|
||||
|
||||
SimpleLogin is also available on Android and iOS, so you can manage your aliases on the go.
|
||||
|
||||
For any question, feedback or feature request, please join our GitHub forum.
|
||||
You can also join our Reddit or follow our Twitter.
|
||||
|
||||
Best,
|
||||
SimpleLogin Team.
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
from app.mail_sender import mail_sender
|
||||
from job_runner import welcome_proton
|
||||
from tests.utils import create_new_user
|
||||
|
||||
|
||||
@mail_sender.store_emails_test_decorator
|
||||
def test_send_welcome_proton_email():
|
||||
user = create_new_user()
|
||||
welcome_proton(user)
|
||||
sent_mails = mail_sender.get_stored_emails()
|
||||
assert len(sent_mails) == 1
|
||||
sent_mail = sent_mails[0]
|
||||
to_email, _, _ = user.get_communication_email()
|
||||
sent_mail.envelope_to = to_email
|
|
@ -1,4 +1,6 @@
|
|||
from app.models import User
|
||||
from app import config
|
||||
from app.db import Session
|
||||
from app.models import User, Job
|
||||
from tests.utils import create_new_user, random_email
|
||||
|
||||
|
||||
|
@ -15,3 +17,7 @@ def test_create_from_partner(flask_client):
|
|||
)
|
||||
assert user.notification is False
|
||||
assert user.trial_end is None
|
||||
job = Session.query(Job).order_by(Job.id.desc()).first()
|
||||
assert job is not None
|
||||
assert job.name == config.JOB_SEND_PROTON_WELCOME_1
|
||||
assert job.payload.get("user_id") == user.id
|
||||
|
|
Loading…
Reference in New Issue