Rename get all intents method
This commit is contained in:
parent
ab5c4b291e
commit
8e05899b0f
@ -4,7 +4,7 @@ const redis = models.redis;
|
|||||||
const {sequelize, Sequelize} = db;
|
const {sequelize, Sequelize} = db;
|
||||||
const Intent = db.intent;
|
const Intent = db.intent;
|
||||||
|
|
||||||
exports.getIntents = async (req, res) => {
|
exports.getAllIntents = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const intents = await Intent.findAll();
|
const intents = await Intent.findAll();
|
||||||
|
|
||||||
@ -14,4 +14,34 @@ exports.getIntents = async (req, res) => {
|
|||||||
|
|
||||||
return res.status(500).send({message: err.message || "Internal server error."});
|
return res.status(500).send({message: err.message || "Internal server error."});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.getIntentCommand = async (req, res) => {
|
||||||
|
try {
|
||||||
|
const {text, device_id} = req.body;
|
||||||
|
|
||||||
|
if (!text || !device_id) {
|
||||||
|
return res.status(400).json({
|
||||||
|
error: 'Missing required fields: text, device_id',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n[FALLBACK API] Processing intent.`);
|
||||||
|
|
||||||
|
const intents = await Intent.findAll();
|
||||||
|
const intent = intents.find(intent => intent.description === text);
|
||||||
|
|
||||||
|
if (command) {
|
||||||
|
const commandId = await redis.client.xAdd(
|
||||||
|
'commands',
|
||||||
|
'*',
|
||||||
|
{
|
||||||
|
device_id: device_id,
|
||||||
|
intent: intent.command,
|
||||||
|
processed_at: new Date().toISOString(),
|
||||||
|
source: 'fallback_api',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,6 +13,6 @@ const controller = require("../controllers/intent.controller");
|
|||||||
// Intent routes
|
// Intent routes
|
||||||
|
|
||||||
// Get all intents
|
// Get all intents
|
||||||
router.get("/", /*[authJwt.verifyToken, authJwt.isAdmin],*/ controller.getIntents);
|
router.get("/", /*[authJwt.verifyToken, authJwt.isAdmin],*/ controller.getAllIntents);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
Loading…
Reference in New Issue
Block a user