From d537c47cbffdc1235ef3dc88f682a126835b3fc4 Mon Sep 17 00:00:00 2001 From: flifloo Date: Sat, 30 May 2020 17:09:44 +0200 Subject: [PATCH] Fix command query on change state --- sockets/clearCommand.js | 2 +- sockets/errorCommand.js | 2 +- sockets/giveCommand.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sockets/clearCommand.js b/sockets/clearCommand.js index db5fbc6..e9ceaf6 100644 --- a/sockets/clearCommand.js +++ b/sockets/clearCommand.js @@ -4,7 +4,7 @@ const utils = require("./utils"); module.exports = socket => { return async (data) => { try { - let c = await models.Command.findByPk(data); + let c = await models.Command.findOne({where: {number: {[models.Sequelize.Op.eq]: data}, date: {[models.Sequelize.Op.eq]: new Date()}}}); if (!c) throw new Error("Command not found"); c.done = null; diff --git a/sockets/errorCommand.js b/sockets/errorCommand.js index 28f172e..8017a2f 100644 --- a/sockets/errorCommand.js +++ b/sockets/errorCommand.js @@ -3,7 +3,7 @@ const models = require("../models"); module.exports = socket => { return async (data) => { try { - let c = await models.Command.findByPk(data); + let c = await models.Command.findOne({where: {number: {[models.Sequelize.Op.eq]: data}, date: {[models.Sequelize.Op.eq]: new Date()}}}); if (!c) throw new Error("Command not found"); diff --git a/sockets/giveCommand.js b/sockets/giveCommand.js index 1b176af..880feb3 100644 --- a/sockets/giveCommand.js +++ b/sockets/giveCommand.js @@ -4,7 +4,7 @@ const utils = require("./utils"); module.exports = socket => { return async (data) => { try { - let c = await models.Command.findByPk(data); + let c = await models.Command.findOne({where: {number: {[models.Sequelize.Op.eq]: data}, date: {[models.Sequelize.Op.eq]: new Date()}}}); if (!c) throw new Error("Command not found");