From 120a0670c47acbe5541e5996230e08e36ea4f2a6 Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 13 Jun 2017 14:59:45 +0200 Subject: fix silent match duplication --- worker.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/worker.js b/worker.js index 4e3a7c1..3a7e370 100644 --- a/worker.js +++ b/worker.js @@ -166,14 +166,16 @@ function flatten(obj) { const match = JSON.parse(msg.content); // deduplicate and reject immediately if (await model.Match.count({ where: { api_id: match.id } }) > 0) { - // send match_dupe to web player.ign.api_id - await ch.publish("amq.topic", - msg.properties.headers.notify + "." + match.id, - new Buffer("match_dupe")) - await ch.nack(msg, false, false); // discard - return; - } - match_data.add(match); + if (msg.properties.headers.notify != undefined) { + await ch.publish("amq.topic", + msg.properties.headers.notify, + new Buffer("matches_dupe")) + // send match_dupe to web player.ign.api_id + await ch.publish("amq.topic", + msg.properties.headers.notify + "." + match.id, + new Buffer("match_dupe")) + } + } else match_data.add(match); msg_buffer.add(msg); } if (msg.properties.type == "telemetry") { @@ -783,6 +785,7 @@ function flatten(obj) { // new match if (m.properties.type == "match") { notif = "matches_update"; + // TODO this sends match_update for every match in the batch to every player // notify player.name.api_id about match_update await Promise.map(match_records, async (mat) => await ch.publish("amq.topic", -- cgit v1.3.1