summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-08-25 23:07:07 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2017-08-25 23:07:07 +0200
commit107593094876a87adc95d9695701cb97faea1236 (patch)
tree3a6b14ccc254b906637dc9905a726b8fcb3c15af
parent93aa94dc157db3c722e1f1921df983bde9c4bd00 (diff)
downloadprocessor-107593094876a87adc95d9695701cb97faea1236.tar.gz
processor-107593094876a87adc95d9695701cb97faea1236.zip
clone msg objects to allow resending 1:1 into the failed queue
-rw-r--r--worker.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/worker.js b/worker.js
index ac5c69f..22b4542 100644
--- a/worker.js
+++ b/worker.js
@@ -333,7 +333,9 @@ amqp.connect(RABBITMQ_URI).then(async (rabbit) => {
// populate `_records`
// data from `/players`
player_objects.forEach((msg) => {
- let player = flatten(msg.content);
+ // flatten a deep clone, the original object is needed
+ // so it can be moved into the failed queue
+ let player = flatten(JSON.parse(JSON.stringify(msg.content)));
player.created_at = new Date(Date.parse(player.created_at));
player.last_match_created_date = player.created_at;
@@ -351,7 +353,7 @@ amqp.connect(RABBITMQ_URI).then(async (rabbit) => {
// data from `/matches`
match_objects.forEach((msg) => {
- let match = msg.content;
+ let match = JSON.parse(JSON.stringify(msg.content)); // deep clone
match.createdAt = new Date(Date.parse(match.createdAt));
// flatten jsonapi nested response into our db structure-like shape