Add release URLs and squish bug
This commit is contained in:
parent
0223b2ea7a
commit
f28e42c42f
|
@ -69,6 +69,7 @@ class Agora(object):
|
||||||
return False
|
return False
|
||||||
if dash["response"]["data"]["contact_count"] > 0:
|
if dash["response"]["data"]["contact_count"] > 0:
|
||||||
for contact in dash["response"]["data"]["contact_list"]:
|
for contact in dash["response"]["data"]["contact_list"]:
|
||||||
|
print(f"CONTACT {contact}")
|
||||||
contact_id = contact["data"]["contact_id"]
|
contact_id = contact["data"]["contact_id"]
|
||||||
current_trades.append(contact_id)
|
current_trades.append(contact_id)
|
||||||
buyer = contact["data"]["buyer"]["username"]
|
buyer = contact["data"]["buyer"]["username"]
|
||||||
|
@ -85,11 +86,37 @@ class Agora(object):
|
||||||
self.last_dash.add(contact_id)
|
self.last_dash.add(contact_id)
|
||||||
|
|
||||||
# Purge old trades from cache
|
# Purge old trades from cache
|
||||||
for trade in self.last_dash:
|
for trade in list(self.last_dash): # We're removing from the list on the fly
|
||||||
if trade not in current_trades:
|
if trade not in current_trades:
|
||||||
self.last_dash.remove(trade)
|
self.last_dash.remove(trade)
|
||||||
return dash_tmp
|
return dash_tmp
|
||||||
|
|
||||||
|
def dashboard_release_urls(self):
|
||||||
|
"""
|
||||||
|
Get information about our open trades.
|
||||||
|
Post new trades to IRC and cache trades for the future.
|
||||||
|
:return: human readable list of strings about our trades or False
|
||||||
|
:rtype: list or bool
|
||||||
|
"""
|
||||||
|
dash = self.agora.dashboard_seller()
|
||||||
|
dash_tmp = []
|
||||||
|
if "data" not in dash["response"]:
|
||||||
|
return False
|
||||||
|
if dash["response"]["data"]["contact_count"] > 0:
|
||||||
|
for contact in dash["response"]["data"]["contact_list"]:
|
||||||
|
contact_id = contact["data"]["contact_id"]
|
||||||
|
buyer = contact["data"]["buyer"]["username"]
|
||||||
|
amount = contact["data"]["amount"]
|
||||||
|
amount_xmr = contact["data"]["amount_xmr"]
|
||||||
|
currency = contact["data"]["currency"]
|
||||||
|
release_url = contact["actions"]["release_url"]
|
||||||
|
if not contact["data"]["is_selling"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
dash_tmp.append(f"{contact_id}: {buyer} {amount}{currency} {amount_xmr}XMR {release_url}")
|
||||||
|
|
||||||
|
return dash_tmp
|
||||||
|
|
||||||
def get_messages(self, contact_id, send_irc=True):
|
def get_messages(self, contact_id, send_irc=True):
|
||||||
"""
|
"""
|
||||||
Get messages for a certain trade ID.
|
Get messages for a certain trade ID.
|
||||||
|
@ -113,7 +140,7 @@ class Agora(object):
|
||||||
self.irc.client.msg(self.irc.client.channel, x)
|
self.irc.client.msg(self.irc.client.channel, x)
|
||||||
return messages_tmp
|
return messages_tmp
|
||||||
|
|
||||||
def get_all_messages(self):
|
def get_all_messages(self, send_irc=True):
|
||||||
"""
|
"""
|
||||||
Get all messages for all open trades.
|
Get all messages for all open trades.
|
||||||
:return: dict of lists keyed by trade/contact ID
|
:return: dict of lists keyed by trade/contact ID
|
||||||
|
@ -122,11 +149,11 @@ class Agora(object):
|
||||||
dash = self.dashboard_id_only()
|
dash = self.dashboard_id_only()
|
||||||
messages_tmp = {}
|
messages_tmp = {}
|
||||||
for contact_id in dash:
|
for contact_id in dash:
|
||||||
messages = self.get_messages(contact_id)
|
messages = self.get_messages(contact_id, send_irc=send_irc)
|
||||||
messages_tmp[contact_id] = messages
|
messages_tmp[contact_id] = messages
|
||||||
|
|
||||||
# Purge old trades from cache
|
# Purge old trades from cache
|
||||||
for trade in self.last_messages:
|
for trade in list(self.last_messages): # We're removing from the list on the fly
|
||||||
if trade not in messages_tmp:
|
if trade not in messages_tmp:
|
||||||
del self.last_messages[trade]
|
del self.last_messages[trade]
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,9 @@ class WebApp(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.log = Logger("webapp")
|
self.log = Logger("webapp")
|
||||||
|
|
||||||
|
def set_tx(self, tx):
|
||||||
|
self.tx = tx
|
||||||
|
|
||||||
@app.route("/callback", methods=["POST"])
|
@app.route("/callback", methods=["POST"])
|
||||||
def callback(self, request):
|
def callback(self, request):
|
||||||
content = request.content.read()
|
content = request.content.read()
|
||||||
|
@ -77,6 +80,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
# Define WebApp
|
# Define WebApp
|
||||||
webapp = WebApp()
|
webapp = WebApp()
|
||||||
|
webapp.set_tx(tx)
|
||||||
# Handle setting up JWT and request_token from an auth code
|
# Handle setting up JWT and request_token from an auth code
|
||||||
if settings.Revolut.SetupToken == "1":
|
if settings.Revolut.SetupToken == "1":
|
||||||
deferLater(reactor, 1, revolut.setup_auth)
|
deferLater(reactor, 1, revolut.setup_auth)
|
||||||
|
|
Loading…
Reference in New Issue