Fix undefined variables in redis stream
This commit is contained in:
parent
2d84f16e8a
commit
39f6c03787
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user