summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-06-13 14:59:45 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2017-06-13 14:59:45 +0200
commit120a0670c47acbe5541e5996230e08e36ea4f2a6 (patch)
treeeb9fde9b234729fc4a71452f3fd7e8db1bb6b798
parent1701b457d7adab467e1d60738039fa3cedf434fa (diff)
downloadprocessor-120a0670c47acbe5541e5996230e08e36ea4f2a6.tar.gz
processor-120a0670c47acbe5541e5996230e08e36ea4f2a6.zip
fix silent match duplication
-rw-r--r--worker.js19
1 files 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",