149 lines
5.2 KiB
Python
149 lines
5.2 KiB
Python
from flask.ext.mail import Message
|
|
|
|
from app import mail, app, get_app_url
|
|
|
|
|
|
CONFIRM_MESSAGE = """
|
|
This email address was recently used to register the username '%s'
|
|
at <a href="%s">Quay.io</a>.<br>
|
|
<br>
|
|
To confirm this email address, please click the following link:<br>
|
|
<a href="%s/confirm?code=%s">%s/confirm?code=%s</a>
|
|
"""
|
|
|
|
|
|
CHANGE_MESSAGE = """
|
|
This email address was recently asked to become the new e-mail address for username '%s'
|
|
at <a href="%s">Quay.io</a>.<br>
|
|
<br>
|
|
To confirm this email address, please click the following link:<br>
|
|
<a href="%s/confirm?code=%s">%s/confirm?code=%s</a>
|
|
"""
|
|
|
|
|
|
RECOVERY_MESSAGE = """
|
|
A user at <a href="%s">Quay.io</a> has attempted to recover their account
|
|
using this email address.<br>
|
|
<br>
|
|
If you made this request, please click the following link to recover your account and
|
|
change your password:
|
|
<a href="%s/recovery?code=%s">%s/recovery?code=%s</a><br>
|
|
<br>
|
|
If you did not make this request, your account has not been compromised and the user was
|
|
not given access. Please disregard this email.<br>
|
|
"""
|
|
|
|
|
|
SUBSCRIPTION_CHANGE = """
|
|
Change: {0}<br>
|
|
Customer id: <a href="https://manage.stripe.com/customers/{1}">{1}</a><br>
|
|
Customer email: <a href="mailto:{2}">{2}</a><br>
|
|
Quay user or org name: {3}<br>
|
|
"""
|
|
|
|
|
|
PAYMENT_FAILED = """
|
|
Hi {0},<br>
|
|
<br>
|
|
Your recent payment for Quay.io failed, which usually results in our payments processorcanceling
|
|
your subscription automatically. If you would like to continue to use Quay.io without interruption,
|
|
please add a new card to Quay.io and re-subscribe to your plan.<br>
|
|
<br>
|
|
You can find the card and subscription management features under your account settings.<br>
|
|
<br>
|
|
Thanks and have a great day!<br>
|
|
<br>
|
|
-Quay.io Support<br>
|
|
"""
|
|
|
|
|
|
AUTH_FORREPO_MESSAGE = """
|
|
A request has been made to send notifications to this email address for the
|
|
<a href="%s">Quay.io</a> repository <a href="%s/repository/%s/%s">%s/%s</a>.
|
|
<br>
|
|
To confirm this email address, please click the following link:<br>
|
|
<a href="%s/authrepoemail?code=%s">%s/authrepoemail?code=%s</a>
|
|
"""
|
|
|
|
INVITE_TO_ORG_TEAM_MESSAGE = """
|
|
Hi {0},<br>
|
|
{1} has invited you to join the team <b>{2}</b> under organization <b>{3}</b> on <a href="{4}">{5}</a>.
|
|
<br><br>
|
|
To join the team, please click the following link:<br>
|
|
<a href="{4}/confirminvite?code={6}">{4}/confirminvite?code={6}</a>
|
|
<br><br>
|
|
If you were not expecting this invitation, you can ignore this email.
|
|
<br><br>
|
|
Thanks,<br>
|
|
- {5} Support
|
|
"""
|
|
|
|
|
|
SUBSCRIPTION_CHANGE_TITLE = 'Subscription Change - {0} {1}'
|
|
|
|
|
|
def send_change_email(username, email, token):
|
|
msg = Message('Quay.io email change. Please confirm your email.',
|
|
sender='support@quay.io', # Why do I need this?
|
|
recipients=[email])
|
|
msg.html = CHANGE_MESSAGE % (username, get_app_url(), get_app_url(), token, get_app_url(), token)
|
|
mail.send(msg)
|
|
|
|
|
|
def send_confirmation_email(username, email, token):
|
|
msg = Message('Welcome to Quay.io! Please confirm your email.',
|
|
sender='support@quay.io', # Why do I need this?
|
|
recipients=[email])
|
|
msg.html = CONFIRM_MESSAGE % (username, get_app_url(), get_app_url(), token, get_app_url(), token)
|
|
mail.send(msg)
|
|
|
|
|
|
def send_repo_authorization_email(namespace, repository, email, token):
|
|
msg = Message('Quay.io Notification: Please confirm your email.',
|
|
sender='support@quay.io', # Why do I need this?
|
|
recipients=[email])
|
|
msg.html = AUTH_FORREPO_MESSAGE % (get_app_url(), get_app_url(), namespace, repository, namespace,
|
|
repository, get_app_url(), token, get_app_url(), token)
|
|
mail.send(msg)
|
|
|
|
|
|
def send_recovery_email(email, token):
|
|
msg = Message('Quay.io account recovery.',
|
|
sender='support@quay.io', # Why do I need this?
|
|
recipients=[email])
|
|
msg.html = RECOVERY_MESSAGE % (get_app_url(), get_app_url(), token, get_app_url(), token)
|
|
mail.send(msg)
|
|
|
|
|
|
def send_invoice_email(email, contents):
|
|
msg = Message('Quay.io payment received - Thank you!',
|
|
sender='support@quay.io', # Why do I need this?
|
|
recipients=[email])
|
|
msg.html = contents
|
|
mail.send(msg)
|
|
|
|
|
|
def send_subscription_change(change_description, customer_id, customer_email, quay_username):
|
|
title = SUBSCRIPTION_CHANGE_TITLE.format(quay_username, change_description)
|
|
msg = Message(title, sender='support@quay.io', recipients=['stripe@quay.io'])
|
|
msg.html = SUBSCRIPTION_CHANGE.format(change_description, customer_id, customer_email,
|
|
quay_username)
|
|
mail.send(msg)
|
|
|
|
|
|
def send_payment_failed(customer_email, quay_username):
|
|
msg = Message('Quay.io Subscription Payment Failure', sender='support@quay.io',
|
|
recipients=[customer_email])
|
|
msg.html = PAYMENT_FAILED.format(quay_username)
|
|
mail.send(msg)
|
|
|
|
|
|
def send_org_invite_email(member_name, member_email, orgname, team, adder, code):
|
|
app_title = app.config['REGISTRY_TITLE_SHORT']
|
|
app_url = get_app_url()
|
|
|
|
title = '%s has invited you to join a team in %s' % (adder, app_title)
|
|
msg = Message(title, sender='support@quay.io', recipients=[member_email])
|
|
msg.html = INVITE_TO_ORG_TEAM_MESSAGE.format(member_name, adder, team, orgname,
|
|
app_url, app_title, code)
|
|
mail.send(msg)
|