mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
api: Add include_sent offers filter.
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
name = "basicswap"
|
||||
|
||||
__version__ = "0.11.57"
|
||||
__version__ = "0.11.58"
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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']
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user