diff --git a/r2/r2/lib/emailer.py b/r2/r2/lib/emailer.py index 87b6766a2..7eff9c764 100644 --- a/r2/r2/lib/emailer.py +++ b/r2/r2/lib/emailer.py @@ -268,6 +268,10 @@ def finished_promo(thing): return _promo_email(thing, Email.Kind.FINISHED_PROMO) +def refunded_promo(thing): + return _promo_email(thing, Email.Kind.REFUNDED_CAMPAIGN) + + def send_html_email(to_addr, from_addr, subject, html, subtype="html"): from r2.lib.filters import _force_utf8 msg = MIMEText(_force_utf8(html), subtype) diff --git a/r2/r2/lib/promote.py b/r2/r2/lib/promote.py index a8de962c9..ff227e8f2 100644 --- a/r2/r2/lib/promote.py +++ b/r2/r2/lib/promote.py @@ -838,6 +838,7 @@ def refund_campaign(link, camp, billable_amount): camp.refund_amount = refund_amount camp._commit() unset_underdelivered_campaigns(camp) + emailer.refunded_promo(link) PromoTuple = namedtuple('PromoTuple', ['link', 'weight', 'campaign']) diff --git a/r2/r2/models/mail_queue.py b/r2/r2/models/mail_queue.py index 47160ec14..8c69431f6 100644 --- a/r2/r2/models/mail_queue.py +++ b/r2/r2/models/mail_queue.py @@ -303,6 +303,7 @@ class Email(object): "GOLDMAIL", "PASSWORD_CHANGE", "EMAIL_CHANGE", + "REFUNDED_PROMO", ) subjects = { @@ -324,6 +325,7 @@ class Email(object): Kind.GOLDMAIL : _("[reddit] reddit gold activation link"), Kind.PASSWORD_CHANGE : _("[reddit] your password has been changed"), Kind.EMAIL_CHANGE : _("[reddit] your email address has been changed"), + Kind.REFUNDED_PROMO: _("[reddit] your campaign didn't get enough impressions") } def __init__(self, user, thing, email, from_name, date, ip, banned_ip, diff --git a/r2/r2/templates/promo_email.email b/r2/r2/templates/promo_email.email index f3bfc480c..aeb11855f 100644 --- a/r2/r2/templates/promo_email.email +++ b/r2/r2/templates/promo_email.email @@ -108,6 +108,13 @@ Thank you again for advertising on reddit, we hope you'll come back and do busin http://www.reddit.com/r/selfserve We're hoping to create a place for you to exchange tips and tricks for getting the most out of your sponsored links, as well as to provide support for new users. +%elif thing.kind == Email.Kind.REFUNDED_PROMO: +We're sorry, but we weren't able to deliver as many impressions as you paid for. + + ${edit_url} + +We're working to improve the systems to predict our pageview inventory so this doesn't happen again. You have been refunded the unspent portion of your budget. If you have any questions or concerns please reply to this email. + %endif Thank you,