82 lines
2.7 KiB
Python
82 lines
2.7 KiB
Python
from flask.ext.mail import Message
|
|
|
|
from app import mail, app
|
|
|
|
|
|
CONFIRM_MESSAGE = """
|
|
This email address was recently used to register the 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>
|
|
"""
|
|
|
|
|
|
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>
|
|
"""
|
|
|
|
|
|
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>
|
|
"""
|
|
|
|
|
|
SUBSCRIPTION_CHANGE = """
|
|
Event name: {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>
|
|
"""
|
|
|
|
|
|
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)
|
|
|
|
|
|
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, token, 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 % (token, 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(event_name, customer_id, customer_email, quay_username):
|
|
msg = Message('Quay.io Customer Subscription Change',
|
|
sender='support@quay.io', # Why do I need this?
|
|
recipients=['stripe@quay.io'])
|
|
msg.html = SUBSCRIPTION_CHANGE.format(event_name, customer_id, customer_email, quay_username)
|
|
mail.send(msg)
|