Allow checking account ID whitelist
This commit is contained in:
@@ -665,7 +665,7 @@ class LocalPlatformClient(ABC):
|
||||
(
|
||||
supported_currencies,
|
||||
account_info,
|
||||
) = self.get_valid_account_details()
|
||||
) = self.get_valid_account_details(ad)
|
||||
# Let's get rid of the ad IDs and make it a tuple like dist_list
|
||||
our_ads = [(x[0], x[2], x[3], x[4]) for x in our_ads]
|
||||
if not our_ads:
|
||||
@@ -704,7 +704,7 @@ class LocalPlatformClient(ABC):
|
||||
(
|
||||
supported_currencies,
|
||||
account_info,
|
||||
) = self.get_valid_account_details(self.name)
|
||||
) = self.get_valid_account_details(ad)
|
||||
if not our_ads:
|
||||
log.error("Could not get our ads.")
|
||||
return False
|
||||
@@ -935,7 +935,7 @@ class LocalPlatformClient(ABC):
|
||||
log.info(f"Sending bank details/reference for {trade_id}")
|
||||
if self.instance.send is True:
|
||||
print("SEND IS TRUE")
|
||||
account_info = self.get_matching_account_details(currency)
|
||||
account_info = self.get_matching_account_details(currency, ad)
|
||||
print("ACCOUNT INFO", account_info)
|
||||
formatted_account_info = self.format_payment_details(
|
||||
currency, account_info, ad, real=True
|
||||
@@ -1141,14 +1141,24 @@ class LocalPlatformClient(ABC):
|
||||
else:
|
||||
yield (asset, countrycode, currency, provider)
|
||||
|
||||
def get_valid_account_details(self):
|
||||
def get_valid_account_details(self, ad):
|
||||
currencies = self.instance.currencies
|
||||
account_info = self.instance.account_info
|
||||
print("GET VALID", ad)
|
||||
account_whitelist = ad.account_whitelist
|
||||
if account_whitelist:
|
||||
whitelist = account_whitelist.splitlines()
|
||||
else:
|
||||
whitelist = None
|
||||
print("WHITELIST", whitelist)
|
||||
currency_account_info_map = {}
|
||||
for currency in currencies:
|
||||
for bank, accounts in account_info.items():
|
||||
for account in accounts:
|
||||
if account["currency"] == currency:
|
||||
if whitelist:
|
||||
if account["account_id"] not in whitelist:
|
||||
continue
|
||||
currency_account_info_map[currency] = account["account_number"]
|
||||
currency_account_info_map[currency]["bank"] = bank.split("_")[0]
|
||||
currency_account_info_map[currency]["recipient"] = account[
|
||||
@@ -1156,11 +1166,11 @@ class LocalPlatformClient(ABC):
|
||||
]
|
||||
return (currencies, currency_account_info_map)
|
||||
|
||||
def get_matching_account_details(self, currency):
|
||||
def get_matching_account_details(self, currency, ad):
|
||||
(
|
||||
supported_currencies,
|
||||
currency_account_info_map,
|
||||
) = self.get_valid_account_details()
|
||||
) = self.get_valid_account_details(ad)
|
||||
if currency not in supported_currencies:
|
||||
return False
|
||||
return currency_account_info_map[currency]
|
||||
|
||||
Reference in New Issue
Block a user