api: Add include_sent offers filter.

This commit is contained in:
tecnovert
2023-01-11 10:28:57 +02:00
parent 9729dcf526
commit 553af1a3e8
7 changed files with 19 additions and 7 deletions

View File

@@ -1,3 +1,3 @@
name = "basicswap"
__version__ = "0.11.57"
__version__ = "0.11.58"

View File

@@ -5838,6 +5838,9 @@ class BasicSwap(BaseApp):
filter_coin_to = filters.get('coin_to', None)
if filter_coin_to and filter_coin_to > -1:
q = q.filter(Offer.coin_to == int(filter_coin_to))
filter_include_sent = filters.get('include_sent', None)
if filter_include_sent and filter_include_sent is not True:
q = q.filter(Offer.was_sent == False) # noqa: E712
order_dir = filters.get('sort_dir', 'desc')
order_by = filters.get('sort_by', 'created_at')

View File

@@ -171,6 +171,8 @@ def js_offers(self, url_split, post_string, is_json, sent=False) -> bytes:
assert (filters['limit'] > 0 and filters['limit'] <= PAGE_LIMIT), 'Invalid limit'
if have_data_entry(post_data, 'active'):
filters['active'] = get_data_entry(post_data, 'active')
if have_data_entry(post_data, 'include_sent'):
filters['include_sent'] = toBool(get_data_entry(post_data, 'include_sent'))
offers = swap_client.listOffers(sent, filters)
rv = []

View File

@@ -47,6 +47,8 @@ def ensure(v, err_string):
def toBool(s) -> bool:
if isinstance(s, bool):
return s
return s.lower() in ['1', 'true']