diff --git a/src/controllers/intent.controller.js b/src/controllers/intent.controller.js index 6d1d077..e4f4bad 100644 --- a/src/controllers/intent.controller.js +++ b/src/controllers/intent.controller.js @@ -22,7 +22,6 @@ exports.getAllIntents = async (req, res) => { exports.getIntentCommand = async (req, res) => { try { const {text, device_id} = req.body; - console.log(req.body, text, device_id); if (!text || !device_id) { return res.status(400).json({ @@ -34,18 +33,15 @@ exports.getIntentCommand = async (req, res) => { await redis.client.connect().catch(console.error) - const intents = await Intent.findAll(); - const intent = intents.find(obj => obj.description === text); - - console.log(intents, intent); + const intent = await Intent.findOne({ where: { description: req.body.text } }); if (intent) { const commandId = await redis.client.xAdd( 'communication', '*', { - device_id: config.DEVICE_ID, - command: intent.command, + device_id: device_id, + command: intent.dataValues.command, processed_at: new Date().toISOString(), source: config.DEVICE_ID, } @@ -66,7 +62,6 @@ exports.getIntentCommand = async (req, res) => { '*', { device_id: device_id, - intent: 'error', command: 'intent_not_found', processed_at: new Date().toISOString(), source: config.DEVICE_ID