From e8da204a3064d6cc3d655e94413e7cdb85e381c7 Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Fri, 6 Mar 2020 15:07:50 +0100 Subject: [PATCH] Fix: send fullgame without irrelevant fields --- client/src/views/Game.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 8e03a861..91e6b6af 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -387,7 +387,20 @@ export default { } break; case "askfullgame": - this.send("fullgame", { data: this.game, target: data.from }); + const gameToSend = Object.keys(this.game) + .filter(k => + [ + "id","fen","players","vid","cadence","fenStart","vname", + "moves","clocks","initime","score","drawOffer" + ].includes(k)) + .reduce( + (obj, k) => { + obj[k] = this.game[k]; + return obj; + }, + {} + ); + this.send("fullgame", { data: gameToSend, target: data.from }); break; case "fullgame": // Callback "roomInit" to poll clients only after game is loaded @@ -641,7 +654,7 @@ export default { } } } - if (game.drawOffer) { + if (!!game.drawOffer) { if (game.drawOffer == "t") // Three repetitions this.drawOffer = "threerep"; -- 2.44.0