Address syntax issues and convert release_trade to async
This commit is contained in:
parent
fe1ff870e2
commit
79caec1680
|
@ -61,7 +61,7 @@ class AgoraDesk:
|
|||
try:
|
||||
text = yield response.content()
|
||||
except: # noqa
|
||||
self.log.error(f"Error with API call")
|
||||
self.log.error("Error with API call")
|
||||
return
|
||||
try:
|
||||
result["response"] = json.loads(text)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Twisted/Klein imports
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
|
||||
# Other library imports
|
||||
from json import dumps
|
||||
from random import choices
|
||||
|
@ -95,7 +98,7 @@ class Transactions(util.Base):
|
|||
# Amount is reliable here as it is checked by find_trade, so no need for stored_trade["amount"]
|
||||
if float(amount_usd) > float(settings.Agora.AcceptableAltLookupUSD):
|
||||
self.log.info("Not checking against amount and currency as amount exceeds MAX")
|
||||
self.irc.sendmsg(f"Not checking against amount and currency as amount exceeds MAX")
|
||||
self.irc.sendmsg("Not checking against amount and currency as amount exceeds MAX")
|
||||
# Close here if the amount exceeds the allowable limit for no reference
|
||||
self.ux.notify.notify_tx_lookup_failed(currency, amount, reference, "EXCEEDS_MAX")
|
||||
return False
|
||||
|
@ -166,6 +169,7 @@ class Transactions(util.Base):
|
|||
return False
|
||||
return True
|
||||
|
||||
@inlineCallbacks
|
||||
def transaction(self, data):
|
||||
"""
|
||||
Store details of transaction and post notifications to IRC.
|
||||
|
@ -252,8 +256,9 @@ class Transactions(util.Base):
|
|||
# self.log.error(f"Cannot release trade {reference}.")
|
||||
# return
|
||||
|
||||
self.release_funds(stored_trade["id"], stored_trade["reference"])
|
||||
yield self.release_funds(stored_trade["id"], stored_trade["reference"])
|
||||
|
||||
@inlineCallbacks
|
||||
def release_funds(self, trade_id, reference):
|
||||
stored_trade = db.get_ref(reference)
|
||||
platform = stored_trade["subclass"]
|
||||
|
@ -267,7 +272,7 @@ class Transactions(util.Base):
|
|||
release = self.lbtc.release_funds
|
||||
post_message = self.lbtc.api.contact_message_post
|
||||
|
||||
rtrn = release(trade_id)
|
||||
rtrn = yield release(trade_id)
|
||||
if rtrn["message"] == "OK":
|
||||
post_message(trade_id, "Thanks! Releasing now :)")
|
||||
else:
|
||||
|
|
|
@ -128,7 +128,7 @@ class TrueLayer(util.Base):
|
|||
if self.current_authcode_bank:
|
||||
self.tokens[self.current_authcode_bank] = access_token
|
||||
else:
|
||||
self.log.error(f"Received an authcode we didn't ask for")
|
||||
self.log.error("Received an authcode we didn't ask for")
|
||||
return
|
||||
self.log.info(f"Retrieved access/refresh tokens for {self.current_authcode_bank}")
|
||||
|
||||
|
|
|
@ -510,10 +510,10 @@ class IRCCommands(object):
|
|||
msg("Trade or TX invalid")
|
||||
return
|
||||
elif is_released is True:
|
||||
msg(f"Trade released")
|
||||
msg("Trade released")
|
||||
return
|
||||
elif is_released is False:
|
||||
msg(f"Could not release trade")
|
||||
msg("Could not release trade")
|
||||
return
|
||||
|
||||
class anuke(object):
|
||||
|
@ -878,7 +878,7 @@ class IRCCommands(object):
|
|||
account_id = spl[2]
|
||||
account_name = tx.sinks.truelayer.map_account(bank, account_id)
|
||||
if not account_name:
|
||||
msg(f"Failed to map the account")
|
||||
msg("Failed to map the account")
|
||||
return
|
||||
msg(f"Mapped account ID {account_id} at bank {bank} to {account_name}")
|
||||
|
||||
|
@ -890,7 +890,7 @@ class IRCCommands(object):
|
|||
@staticmethod
|
||||
def got_map_account(account_name, account_id, msg):
|
||||
if not account_name:
|
||||
msg(f"Failed to map the account")
|
||||
msg("Failed to map the account")
|
||||
return
|
||||
msg(f"Mapped account ID {account_id} to {account_name}")
|
||||
|
||||
|
|
Loading…
Reference in New Issue