diff --git a/inquisitor/app.py b/inquisitor/app.py index 39ff1af..57ab55a 100644 --- a/inquisitor/app.py +++ b/inquisitor/app.py @@ -140,3 +140,10 @@ def mass_deactivate(): logger.debug(f"Deactivating {info['source']}/{info['itemid']}") item['active'] = False return jsonify({}) + +@app.route("/callback/", methods=['POST']) +def callback(): + params = request.get_json() + if 'source' not in params and 'itemid' not in params: + logger.error("Bad request params: {}".format(params)) + return jsonify({}) diff --git a/inquisitor/importer.py b/inquisitor/importer.py index 2f21fd4..04adfc3 100644 --- a/inquisitor/importer.py +++ b/inquisitor/importer.py @@ -155,7 +155,7 @@ def populate_new(source_name, item): if 'title' not in item: item['title'] = item['id'] # tags is auto-populated if missing (not if empty!) if 'tags' not in item: item['tags'] = [source_name] - # link, time, author, body, ttl, ttd, and tts are optional + # link, time, author, body, ttl, ttd, tts, callback are optional def populate_old(prior, new): # Not updated: id, source, active, created @@ -168,3 +168,4 @@ def populate_old(prior, new): if 'ttl' in new: prior['ttl'] = new['ttl'] if 'ttd' in new: prior['ttd'] = new['ttd'] if 'tts' in new: prior['tts'] = new['tts'] + if 'callback' in new: prior['callback'] = new['callback'] diff --git a/inquisitor/templates/feed.html b/inquisitor/templates/feed.html index ac8fdc1..c9bbb3f 100644 --- a/inquisitor/templates/feed.html +++ b/inquisitor/templates/feed.html @@ -73,11 +73,22 @@ }, body: JSON.stringify({items: items}), }) - .then(response => response.json()) .then(function () { location.reload() }); }; + var callback = function (source, itemid) { + fetch('callback/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + body: JSON.stringify({source: source, itemid: itemid}), + }) + .then(function (data) { + location.reload() + }); + };
@@ -88,9 +99,14 @@ {% if item.id %}{% endif %} {% if item.id %}{% endif %} {% if item.link %}⇗{% endif %} - {% if item.body %}{{item.body|safe}}
+ {% endif %} + {% if item.callback %} + + {% endif %}