mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Changed order of operations
This commit is contained in:
+24
-24
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user