2013-09-27 23:29:01 +00:00
|
|
|
from flask.ext.mail import Message
|
|
|
|
|
|
|
|
from app import mail, app
|
|
|
|
|
|
|
|
|
|
|
|
CONFIRM_MESSAGE = """
|
|
|
|
This email address was recently used to register the username '%s'
|
2013-10-14 21:50:07 +00:00
|
|
|
at <a href="https://quay.io">Quay.io</a>.<br>
|
2013-09-27 23:29:01 +00:00
|
|
|
<br>
|
|
|
|
To confirm this email address, please click the following link:<br>
|
2013-10-01 19:48:53 +00:00
|
|
|
<a href="https://quay.io/confirm?code=%s">https://quay.io/confirm?code=%s</a>
|
2013-09-27 23:29:01 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
2014-01-17 22:04:05 +00:00
|
|
|
CHANGE_MESSAGE = """
|
|
|
|
This email address was recently asked to become the new e-mail address for username '%s'
|
|
|
|
at <a href="https://quay.io">Quay.io</a>.<br>
|
|
|
|
<br>
|
|
|
|
To confirm this email address, please click the following link:<br>
|
|
|
|
<a href="https://quay.io/confirm?code=%s">https://quay.io/confirm?code=%s</a>
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2013-10-14 21:50:07 +00:00
|
|
|
RECOVERY_MESSAGE = """
|
|
|
|
A user at <a href="https://quay.io">Quay.io</a> has attempted to recover their account
|
|
|
|
using this email.<br>
|
|
|
|
<br>
|
|
|
|
If you made this request, please click the following link to recover your account and
|
|
|
|
change your password:
|
|
|
|
<a href="https://quay.io/recovery?code=%s">https://quay.io/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>
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2014-04-15 21:00:32 +00:00
|
|
|
SUBSCRIPTION_CHANGE = """
|
2014-04-17 20:18:37 +00:00
|
|
|
Change: {0}<br>
|
2014-04-15 21:00:32 +00:00
|
|
|
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>
|
|
|
|
"""
|
|
|
|
|
2014-04-22 17:56:34 +00:00
|
|
|
|
|
|
|
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>
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2014-04-17 20:18:37 +00:00
|
|
|
SUBSCRIPTION_CHANGE_TITLE = 'Subscription Change - {0} {1}'
|
|
|
|
|
2014-04-15 21:00:32 +00:00
|
|
|
|
2014-01-17 22:04:05 +00:00
|
|
|
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, token, token)
|
|
|
|
mail.send(msg)
|
|
|
|
|
|
|
|
|
2013-09-27 23:29:01 +00:00
|
|
|
def send_confirmation_email(username, email, token):
|
2013-10-14 21:50:07 +00:00
|
|
|
msg = Message('Welcome to Quay.io! Please confirm your email.',
|
2013-10-01 19:48:53 +00:00
|
|
|
sender='support@quay.io', # Why do I need this?
|
2013-09-27 23:29:01 +00:00
|
|
|
recipients=[email])
|
|
|
|
msg.html = CONFIRM_MESSAGE % (username, token, token)
|
|
|
|
mail.send(msg)
|
2013-10-14 21:50:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
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 % (token, token)
|
|
|
|
mail.send(msg)
|
2013-11-15 19:42:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2014-04-15 21:00:32 +00:00
|
|
|
|
|
|
|
|
2014-04-17 20:18:37 +00:00
|
|
|
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)
|
2014-04-15 21:00:32 +00:00
|
|
|
mail.send(msg)
|
2014-04-22 17:56:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|