Rename get all intents method

This commit is contained in:
Apher 2026-06-28 19:52:22 +00:00
parent ab5c4b291e
commit 8e05899b0f
2 changed files with 33 additions and 3 deletions

View File

@ -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();
@ -15,3 +15,33 @@ 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',
}
);
}
}
}

View File

@ -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;