Browse files

ipn: Log errors related to send_system_message.

  • Loading branch information...
1 parent e1263ed commit c295ea07f30d5712032586545d72b86b16daf9f9 @bsimpson63 bsimpson63 committed Mar 6, 2013
Showing with 11 additions and 5 deletions.
  1. +11 −5 r2/r2/controllers/ipn.py
View
16 r2/r2/controllers/ipn.py
@@ -35,6 +35,7 @@
import stripe
from r2.controllers.reddit_base import RedditController
+from r2.lib.errors import MessageError
from r2.lib.filters import _force_unicode, _force_utf8
from r2.lib.log import log_text
from r2.lib.strings import strings
@@ -247,7 +248,11 @@ def send_gift(buyer, recipient, months, days, signed, giftmessage, comment_id):
)
subject = sender + " just sent you reddit gold!"
- send_system_message(recipient, subject, message)
+
+ try:
+ send_system_message(recipient, subject, message)
+ except MessageError:
+ g.log.error('send_gift: could not send system message')
g.log.info("%s gifted %s to %s" % (buyer.name, amount, recipient.name))
return comment
@@ -937,26 +942,22 @@ def complete_gold_purchase(secret, transaction_id, payer_email, payer_id,
message = strings.lounge_msg % dict(link=lounge_url)
else:
message = ":)"
- send_system_message(buyer, subject, message)
else:
subject = "your reddit gold has been renewed!"
message = ("see the details of your subscription on "
"[your userpage](/u/%s)" % buyer.name)
- send_system_message(buyer, subject, message)
elif goldtype == 'creddits':
buyer._incr('gold_creddits', months)
subject = "thanks for buying creddits!"
message = ("To spend them, visit http://%s/gold or your favorite "
"person's userpage." % (g.domain))
- send_system_message(buyer, subject, message)
elif goldtype == 'gift':
send_gift(buyer, recipient, months, days, signed, giftmessage,
comment)
subject = "thanks for giving reddit gold!"
message = "Your gift to %s has been delivered." % recipient.name
- send_system_message(buyer, subject, message)
status = 'processed'
secret_pieces = [goldtype]
@@ -972,6 +973,11 @@ def complete_gold_purchase(secret, transaction_id, payer_email, payer_id,
except IntegrityError:
g.log.error('gold: got duplicate gold transaction')
+ try:
+ send_system_message(buyer, subject, message)
+ except MessageError:
+ g.log.error('complete_gold_purchase: could not send system message')
+
def subtract_gold_days(user, days):
user.gold_expiration -= timedelta(days=days)

0 comments on commit c295ea0

Please sign in to comment.