From 8e2369eff96c4006a5a7e73a14ef8891f17050f1 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 17 Mar 2021 20:59:31 -0700 Subject: [PATCH] Prevent dupliate callbacks --- inquisitor/app.py | 1 + inquisitor/templates/feed.jinja2 | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/inquisitor/app.py b/inquisitor/app.py index d6fd637..00d4b54 100644 --- a/inquisitor/app.py +++ b/inquisitor/app.py @@ -176,6 +176,7 @@ def callback(): params = request.get_json() if 'source' not in params and 'itemid' not in params: logger.error("Bad request params: {}".format(params)) + logger.info('Executing callback for {}/{}'.format(params['source'], params['itemid'])) sources.item_callback(params['source'], params['itemid']) return jsonify({}) diff --git a/inquisitor/templates/feed.jinja2 b/inquisitor/templates/feed.jinja2 index 3e4a9ac..617c620 100644 --- a/inquisitor/templates/feed.jinja2 +++ b/inquisitor/templates/feed.jinja2 @@ -76,10 +76,11 @@ body: JSON.stringify({items: items}), }) .then(function () { - location.reload() + location.reload(); }); }; var callback = function (source, itemid) { + document.getElementById(source + "-" + itemid + "-callback").disabled = true; fetch('/callback/', { method: 'POST', headers: { @@ -107,7 +108,7 @@

{{item.body|safe}}

{% endif %} {% if item.callback %} -

+

{% endif %} {% else %}{{item.title}}