Move reference handling code to DB
This commit is contained in:
@@ -13,6 +13,7 @@ from settings import settings
|
||||
import util
|
||||
from lib.agoradesk_py import AgoraDesk
|
||||
from lib.localbitcoins_py import LocalBitcoins
|
||||
import db
|
||||
|
||||
|
||||
class Local(util.Base):
|
||||
@@ -89,7 +90,7 @@ class Local(util.Base):
|
||||
if dash is False:
|
||||
return False
|
||||
for contact_id, contact in dash.items():
|
||||
reference = self.tx.tx_to_ref(contact_id)
|
||||
reference = db.tx_to_ref(contact_id)
|
||||
buyer = contact["data"]["buyer"]["username"]
|
||||
amount = contact["data"]["amount"]
|
||||
if self.platform == "agora":
|
||||
@@ -123,7 +124,7 @@ class Local(util.Base):
|
||||
if not dash.items():
|
||||
return
|
||||
for contact_id, contact in dash.items():
|
||||
reference = self.tx.tx_to_ref(str(contact_id))
|
||||
reference = db.tx_to_ref(str(contact_id))
|
||||
if reference:
|
||||
current_trades.append(reference)
|
||||
buyer = contact["data"]["buyer"]["username"]
|
||||
@@ -170,7 +171,7 @@ class Local(util.Base):
|
||||
self.last_dash.remove(ref)
|
||||
if reference and reference not in current_trades:
|
||||
current_trades.append(reference)
|
||||
self.tx.cleanup(self.platform, current_trades)
|
||||
db.cleanup(self.platform, current_trades)
|
||||
|
||||
def got_recent_messages(self, messages, send_irc=True):
|
||||
"""
|
||||
@@ -184,14 +185,14 @@ class Local(util.Base):
|
||||
if "data" not in messages["response"]:
|
||||
self.log.error(f"Data not in messages response: {messages['response']}")
|
||||
return False
|
||||
open_tx = self.tx.get_ref_map().keys()
|
||||
open_tx = db.get_ref_map().keys()
|
||||
for message in messages["response"]["data"]["message_list"]:
|
||||
contact_id = message["contact_id"]
|
||||
username = message["sender"]["username"]
|
||||
msg = message["msg"]
|
||||
if contact_id not in open_tx:
|
||||
continue
|
||||
reference = self.tx.tx_to_ref(contact_id)
|
||||
reference = db.tx_to_ref(contact_id)
|
||||
if reference in messages_tmp:
|
||||
messages_tmp[reference].append([username, msg])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user