From: Carl Worth Date: Thu, 11 Jun 2020 14:52:26 +0000 (-0700) Subject: empathy: Fix /prompts endpoint to return the ID of the new prompt X-Git-Url: https://git.cworth.org/git?p=lmno-server;a=commitdiff_plain;h=98d81b7b03f2ad279debd6eb1372ca6746eebd88 empathy: Fix /prompts endpoint to return the ID of the new prompt It never ceases to amaze me the bugs that can only be found when writing tests. (My manual client testing missed this bug because they never looked for this ID, but instead picked up the ID from the broadcast to all clients when a new prompt is added.) --- diff --git a/empathy.js b/empathy.js index 3b613e6..7dbf5d8 100644 --- a/empathy.js +++ b/empathy.js @@ -218,7 +218,9 @@ class Prompt { router.post('/prompts', (request, response) => { const game = request.game; - game.add_prompt(request.body.items, request.body.prompt); + prompt = game.add_prompt(request.body.items, request.body.prompt); + + response.json({ id: prompt.id}); }); router.post('/vote/:prompt_id([0-9]+)', (request, response) => {