Remove DB and clean up references to it
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from abc import ABC
|
||||
|
||||
import orjson
|
||||
|
||||
from core.clients.platforms.agora import AgoraClient
|
||||
from core.lib import notify
|
||||
from core.lib.money import money
|
||||
@@ -52,7 +54,7 @@ class AggregatorClient(ABC):
|
||||
if not transactions:
|
||||
return False
|
||||
|
||||
platforms = self.platforms
|
||||
platforms = self.instance.platforms
|
||||
for transaction in transactions:
|
||||
transaction_id = transaction["transaction_id"]
|
||||
tx_obj = self.instance.get_transaction(
|
||||
@@ -73,6 +75,9 @@ class AggregatorClient(ABC):
|
||||
tx_cast,
|
||||
)
|
||||
# New transaction
|
||||
await notify.sendmsg(
|
||||
f"New transaction: {orjson.dumps(tx_cast)}", title="New transaction"
|
||||
)
|
||||
await self.transaction(platforms, tx_obj)
|
||||
else:
|
||||
# Transaction exists
|
||||
|
||||
@@ -9,7 +9,7 @@ from aiocoingecko import AsyncCoinGeckoAPISession
|
||||
from django.conf import settings
|
||||
|
||||
from core.clients.platforms.api.agoradesk import AgoraDesk
|
||||
from core.lib import db, notify
|
||||
from core.lib import notify
|
||||
from core.lib.antifraud import antifraud
|
||||
from core.lib.money import money
|
||||
from core.util import logs
|
||||
@@ -231,15 +231,14 @@ class LocalPlatformClient(ABC):
|
||||
if "data" not in messages["response"]:
|
||||
log.error(f"Data not in messages response: {messages['response']}")
|
||||
return False
|
||||
ref_map = await db.get_ref_map()
|
||||
open_tx = ref_map.keys()
|
||||
open_tx = self.instance.trade_ids
|
||||
for message in messages["response"]["data"]["message_list"]:
|
||||
contact_id = str(message["contact_id"])
|
||||
username = message["sender"]["username"]
|
||||
msg = message["msg"]
|
||||
if contact_id not in open_tx:
|
||||
continue
|
||||
reference = await db.tx_to_ref(contact_id)
|
||||
reference = self.instance.contact_id_to_reference(contact_id)
|
||||
if reference in messages_tmp:
|
||||
messages_tmp[reference].append([username, msg])
|
||||
else:
|
||||
@@ -860,7 +859,6 @@ class LocalPlatformClient(ABC):
|
||||
"""
|
||||
reference = "".join(choices(ascii_uppercase, k=5))
|
||||
reference = f"AGR-{reference}"
|
||||
existing_ref = await db.r.get(f"trade.{trade_id}.reference")
|
||||
existing_ref = self.instance.contact_id_to_reference(trade_id)
|
||||
if not existing_ref:
|
||||
# to_store = {
|
||||
@@ -929,13 +927,13 @@ class LocalPlatformClient(ABC):
|
||||
:return: tuple of (platform, trade_id, reference, currency)
|
||||
"""
|
||||
platform, username = self.get_uid(uid)
|
||||
refs = await db.get_refs()
|
||||
refs = self.instance.references
|
||||
matching_trades = []
|
||||
for reference in refs:
|
||||
ref_data = await db.get_ref(reference)
|
||||
tx_username = ref_data["buyer"]
|
||||
trade_id = ref_data["id"]
|
||||
currency = ref_data["currency"]
|
||||
ref_data = self.instance.get_trade_by_reference(reference)
|
||||
tx_username = ref_data.buyer
|
||||
trade_id = ref_data.contact_id
|
||||
currency = ref_data.currency
|
||||
if tx_username == username:
|
||||
to_append = (platform, trade_id, reference, currency)
|
||||
matching_trades.append(to_append)
|
||||
|
||||
Reference in New Issue
Block a user