Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit f9c7345

Browse files
committed
Fix up notifications
1 parent d3c9b58 commit f9c7345

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

market/contracts.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,9 @@ def accept_order_confirmation(self, notification_listener, confirmation_json=Non
535535

536536
# Send SMTP notification
537537
notification = SMTPNotification(self.db)
538-
notification.send("[OpenBazaar] Order Confirmed and Shipped: #%s" % contract_hash,
539-
"You have received an order confirmation from %s for \"%s\"" % (vendor_guid, title))
538+
notification.send("[OpenBazaar] Order Confirmed and Shipped",
539+
"You have received an order confirmation.\n\n"
540+
"Order: %s\nVendor: %s\nTitle: %s\n" % (contract_hash, vendor_guid, title))
540541

541542
return True
542543
except Exception, e:
@@ -831,13 +832,16 @@ def await_funding(self, notification_listener, libbitcoin_client, proofSig, is_p
831832
buyer,
832833
self.contract["vendor_offer"]["listing"]["metadata"]["category"])
833834

834-
notification = SMTPNotification(self.db)
835-
notification.send("[OpenBazaar] Order Received", "Order #%s\n"
836-
"Buyer: %s\n"
837-
"BTC Address: %s\n"
838-
"Title: %s\n"
839-
"Description: %s\n"
840-
% (order_id, buyer, payment_address, title, description))
835+
try:
836+
notification = SMTPNotification(self.db)
837+
notification.send("[OpenBazaar] Order Received", "Order #%s\n"
838+
"Buyer: %s\n"
839+
"BTC Address: %s\n"
840+
"Title: %s\n"
841+
"Description: %s\n"
842+
% (order_id, buyer, payment_address, title, description))
843+
except Exception as e:
844+
self.log.info("Error with SMTP notification: %s" % e.message)
841845

842846
with open(file_path, 'w') as outfile:
843847
outfile.write(json.dumps(self.contract, indent=4))
@@ -868,8 +872,8 @@ def on_tx_received(self, address_version, address_hash, height, block_hash, tx):
868872
if self.amount_funded >= amount_to_pay: # if fully funded
869873
self.payment_received()
870874

871-
except Exception:
872-
self.log.critical("Error processing bitcoin transaction")
875+
except Exception as e:
876+
self.log.critical("Error processing bitcoin transaction: %s" % e.message)
873877

874878
def payment_received(self):
875879
self.blockchain.unsubscribe_address(
@@ -892,8 +896,11 @@ def payment_received(self):
892896
order_id, title, image_hash)
893897

894898
notification = SMTPNotification(self.db)
895-
notification.send("[OpenBazaar] Payment Received", "Your payment to %s was received for Order #%s - \"%s\"."
896-
% (unhexlify(vendor_guid), order_id, title))
899+
notification.send("[OpenBazaar] Purchase Payment Received", "Your payment was received.\n\n"
900+
"Order: %s\n"
901+
"Vendor: %s\n"
902+
"Title: %s"
903+
% (order_id, vendor_guid, title))
897904

898905
# update the db
899906
if self.db.purchases.get_status(order_id) == 0:
@@ -912,8 +919,8 @@ def payment_received(self):
912919
title, image_hash)
913920

914921
notification = SMTPNotification(self.db)
915-
notification.send("[OpenBazaar] New Order Received", "You received Order #%s from %s for \"%s\"."
916-
% (order_id, unhexlify(buyer_guid), title))
922+
notification.send("[OpenBazaar] Payment for Order Received", "Payment was received for Order #%s."
923+
% order_id)
917924

918925
self.db.sales.update_status(order_id, 1)
919926
self.db.sales.update_outpoint(order_id, json.dumps(self.outpoints))
@@ -1106,7 +1113,8 @@ def process_refund(self, refund_json, blockchain, notification_listener):
11061113
notification_listener.notify(buyer_guid, handle, "refund", order_id, title, image_hash)
11071114

11081115
notification = SMTPNotification(self.db)
1109-
notification.send("[OpenBazaar] Refund Received", "You received a refund for Order #%s - \"%s\"."
1116+
notification.send("[OpenBazaar] Refund Received", "You received a refund.\n\n"
1117+
"Order: %s\nTitle: %s"
11101118
% (order_id, title))
11111119

11121120
def verify(self, sender_key):

0 commit comments

Comments
 (0)