Changed order of operations

This commit is contained in:
inventor96
2019-09-07 19:49:32 -06:00
parent 58162c2183
commit b39eb8f672
+24 -24
View File
@@ -41,30 +41,6 @@ function configure (app, wares, ctx, env) {
}
});
api.post('/googlehome', ctx.authorization.isPermitted('api:*:read'), function (req, res, next) {
console.log('Incoming request from Google Home');
var locale = req.body.queryResult.languageCode;
if(locale){
if(locale.length > 2) {
locale = locale.substr(0, 2);
}
ctx.language.set(locale);
moment.locale(locale);
}
var handler = ctx.googleHome.getIntentHandler(req.body.queryResult.intent.displayName, req.body.queryResult.parameters);
if (handler){
var sbx = initializeSandbox();
handler(function (title, response) {
res.json(ctx.googleHome.buildSpeechletResponse(response, false));
next( );
}, req.body.queryResult.parameters, sbx);
} else {
res.json(ctx.googleHome.buildSpeechletResponse('I\'m sorry. I don\'t know what you\'re asking for. Could you say that again?', true));
next( );
}
});
ctx.googleHome.addToRollup('Status', function bgRollupHandler(slots, sbx, callback) {
entries.list({count: 1}, function (err, records) {
var direction;
@@ -117,6 +93,30 @@ function configure (app, wares, ctx, env) {
return sbx;
}
api.post('/googlehome', ctx.authorization.isPermitted('api:*:read'), function (req, res, next) {
console.log('Incoming request from Google Home');
var locale = req.body.queryResult.languageCode;
if(locale){
if(locale.length > 2) {
locale = locale.substr(0, 2);
}
ctx.language.set(locale);
moment.locale(locale);
}
var handler = ctx.googleHome.getIntentHandler(req.body.queryResult.intent.displayName, req.body.queryResult.parameters);
if (handler){
var sbx = initializeSandbox();
handler(function (title, response) {
res.json(ctx.googleHome.buildSpeechletResponse(response, false));
next( );
}, req.body.queryResult.parameters, sbx);
} else {
res.json(ctx.googleHome.buildSpeechletResponse('I\'m sorry. I don\'t know what you\'re asking for. Could you say that again?', true));
next( );
}
});
return api;
}