From d9f55ce4973e540be7a9fa08f09850f491a3c3a0 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 17 Feb 2022 12:18:05 +0000 Subject: [PATCH] Add provider to trade information --- handler/agora.py | 8 +++++--- handler/transactions.py | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/handler/agora.py b/handler/agora.py index 3c569d9..f377d8b 100644 --- a/handler/agora.py +++ b/handler/agora.py @@ -130,9 +130,10 @@ class Agora(object): elif asset == "BTC": amount_crypto = contact["data"]["amount_btc"] currency = contact["data"]["currency"] + provider = contact["data"]["advertisement"]["payment_method"] if not contact["data"]["is_selling"]: continue - rtrn.append(f"{reference}: {buyer} {amount}{currency} {amount_crypto}{asset}") + rtrn.append(f"{reference}: {buyer} {amount}{currency} {provider} {amount_crypto}{asset}") return rtrn def dashboard_hook(self, dash): @@ -152,6 +153,7 @@ class Agora(object): buyer = contact["data"]["buyer"]["username"] amount = contact["data"]["amount"] asset = contact["data"]["advertisement"]["asset"] + provider = contact["data"]["advertisement"]["payment_method"] if asset == "XMR": amount_crypto = contact["data"]["amount_xmr"] elif asset == "BTC": @@ -160,12 +162,12 @@ class Agora(object): if not contact["data"]["is_selling"]: continue if reference not in self.last_dash: - reference = self.tx.new_trade(asset, contact_id, buyer, currency, amount, amount_crypto) + reference = self.tx.new_trade(asset, contact_id, buyer, currency, amount, amount_crypto, provider) if reference: if reference not in current_trades: current_trades.append(reference) # Let us know there is a new trade - self.irc.sendmsg(f"AUTO {reference}: {buyer} {amount}{currency} {amount_crypto}{asset}") + self.irc.sendmsg(f"AUTO {reference}: {buyer} {amount}{currency} {provider} {amount_crypto}{asset}") # Note that we have seen this reference self.last_dash.add(reference) diff --git a/handler/transactions.py b/handler/transactions.py index 5e3698c..5487545 100644 --- a/handler/transactions.py +++ b/handler/transactions.py @@ -45,6 +45,7 @@ class Transactions(object): if not stored_trade: self.log.error("Could not find entry in DB for typeless transaction: {id}", id=txid) return + print("BEFORE CONVERT STORED TRADE", stored_trade) stored_trade = convert(stored_trade) if "old_state" in inside: if "new_state" in inside: @@ -240,7 +241,7 @@ class Transactions(object): message_long = rtrn["response"]["data"]["message"] self.irc.sendmsg(f"{message} - {message_long}") - def new_trade(self, asset, trade_id, buyer, currency, amount, amount_crypto): + def new_trade(self, asset, trade_id, buyer, currency, amount, amount_crypto, provider): """ Called when we have a new trade in Agora. Store details in Redis, generate a reference and optionally let the customer know the reference. @@ -258,6 +259,7 @@ class Transactions(object): "amount": amount, "amount_crypto": amount_crypto, "reference": reference, + "provider": provider, } self.log.info("Storing trade information: {info}", info=str(to_store)) r.hmset(f"trade.{reference}", to_store)