]> git.cworth.org Git - lmno-server/commitdiff
empathy: Fix /prompts endpoint to return the ID of the new prompt
authorCarl Worth <cworth@cworth.org>
Thu, 11 Jun 2020 14:52:26 +0000 (07:52 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 11 Jun 2020 14:52:26 +0000 (07:52 -0700)
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.)

empathy.js

index 3b613e672ade0e14e0f4ff03e1b3205b4f78cddd..7dbf5d80c40bf5064a1ee77e091419970aecfd2c 100644 (file)
@@ -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) => {