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

Commit bc10560

Browse files
committed
Change newlines to breaks
Fix migration naming
1 parent 7d4dca9 commit bc10560

File tree

4 files changed

+50
-16
lines changed

4 files changed

+50
-16
lines changed

market/contracts.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ def accept_order_confirmation(self, notification_listener, confirmation_json=Non
536536
# Send SMTP notification
537537
notification = SMTPNotification(self.db)
538538
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))
539+
"You have received an order confirmation.<br><br>"
540+
"Order: %s<br>Vendor: %s<br>Title: %s<br>" % (contract_hash, vendor_guid, title))
541541

542542
return True
543543
except Exception, e:
@@ -834,11 +834,11 @@ def await_funding(self, notification_listener, libbitcoin_client, proofSig, is_p
834834

835835
try:
836836
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"
837+
notification.send("[OpenBazaar] Order Received", "Order #%s<br>"
838+
"Buyer: %s<br>"
839+
"BTC Address: %s<br>"
840+
"Title: %s<br>"
841+
"Description: %s<br>"
842842
% (order_id, buyer, payment_address, title, description))
843843
except Exception as e:
844844
self.log.info("Error with SMTP notification: %s" % e.message)
@@ -896,9 +896,9 @@ def payment_received(self):
896896
order_id, title, image_hash)
897897

898898
notification = SMTPNotification(self.db)
899-
notification.send("[OpenBazaar] Purchase Payment Received", "Your payment was received.\n\n"
900-
"Order: %s\n"
901-
"Vendor: %s\n"
899+
notification.send("[OpenBazaar] Purchase Payment Received", "Your payment was received.<br><br>"
900+
"Order: %s<br>"
901+
"Vendor: %s<br>"
902902
"Title: %s"
903903
% (order_id, vendor_guid, title))
904904

@@ -1113,8 +1113,8 @@ def process_refund(self, refund_json, blockchain, notification_listener):
11131113
notification_listener.notify(buyer_guid, handle, "refund", order_id, title, image_hash)
11141114

11151115
notification = SMTPNotification(self.db)
1116-
notification.send("[OpenBazaar] Refund Received", "You received a refund.\n\n"
1117-
"Order: %s\nTitle: %s"
1116+
notification.send("[OpenBazaar] Refund Received", "You received a refund.<br><br>"
1117+
"Order: %s<br>Title: %s"
11181118
% (order_id, title))
11191119

11201120
def verify(self, sender_key):

market/protocol.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ def rpc_follow(self, sender, proto, signature):
162162
# Send SMTP notification
163163
notification = SMTPNotification(self.db)
164164
notification.send("[OpenBazaar] %s is now following you!" % m.name,
165-
"You have a new follower:\n\nName: %s\nGUID: %s\nHandle: %s" % (m.name,
166-
f.guid.encode('hex'),
167-
m.handle))
165+
"You have a new follower:<br><br>Name: %s<br>GUID: <a href=\"ob://%s\">%s</a><br>"
166+
"Handle: %s" %
167+
(m.name, f.guid.encode('hex'), f.guid.encode('hex'), m.handle))
168168

169169
return ["True", m.SerializeToString(), self.signing_key.sign(m.SerializeToString())[:64]]
170170
except Exception:
@@ -324,8 +324,9 @@ def rpc_dispute_open(self, sender, pubkey, encrypted):
324324
self.router.addContact(sender)
325325
self.log.info("Contract dispute opened by %s" % sender)
326326
return ["True"]
327-
except Exception:
327+
except Exception as e:
328328
self.log.error("unable to parse disputed contract from %s" % sender)
329+
self.log.error("Exception: %s" % e.message)
329330
return ["False"]
330331

331332
def rpc_dispute_close(self, sender, pubkey, encrypted):

migration3.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sqlite3
2+
from protos import objects
3+
4+
5+
def migrate(database_path):
6+
print "migrating to db version 3"
7+
conn = sqlite3.connect(database_path)
8+
conn.text_factory = str
9+
cursor = conn.cursor()
10+
# read followers from db
11+
cursor.execute('''SELECT serializedFollowers FROM followers WHERE id=1''')
12+
followers = cursor.fetchone()
13+
14+
# delete follower table
15+
cursor.execute('''DROP TABLE followers''')
16+
17+
# create new table
18+
cursor.execute('''CREATE TABLE followers(guid TEXT UNIQUE, serializedFollower TEXT)''')
19+
cursor.execute('''CREATE INDEX index_followers ON followers(serializedFollower);''')
20+
21+
# write followers back into db
22+
23+
if followers is not None:
24+
f = objects.Followers()
25+
f.ParseFromString(followers[0])
26+
for follower in f.followers:
27+
cursor.execute('''INSERT INTO followers(guid, serializedFollower) VALUES (?,?)''',
28+
(follower.guid.encode("hex"), follower.SerializeToString().encode("hex"),))
29+
30+
# update version
31+
cursor.execute('''PRAGMA user_version = 3''')
32+
conn.commit()
33+
conn.close()

0 commit comments

Comments
 (0)