fixed PR #15 comments

This commit is contained in:
GotPPay
2018-04-03 14:19:07 +02:00
parent 284cdcd7ba
commit 4a43dda852
11 changed files with 164 additions and 151 deletions

View File

@@ -7,6 +7,7 @@ let predefinedSourceHelper = require ('../helpers/externalSource');
var handlers = {};
var destinationEmail;
let skillName;
module.exports = {
run: function (req, res) {
@@ -33,6 +34,7 @@ module.exports = {
.then (activeSkill => {
handlers = {};
destinationEmail = activeSkill.contactEmail;
skillName = activeSkill.invocationName;
let listOfPossibleQuestions = '';
activeSkill.intents.forEach (intent => {
@@ -77,7 +79,7 @@ module.exports = {
reject: null
}
let answer = new Promise((resolve,reject)=>{
let answerPromise = new Promise ((resolve, reject) => {
answerPromiseProps = {
resolve:resolve,
reject:reject
@@ -88,30 +90,32 @@ module.exports = {
case constants.answerType.PREDEFINED:
answerPromiseProps.resolve(intent.answer);
break;
case constants.answerType.EXTERNAL_SOURCE_WP_JSON:
case constants.answerType.EXTERNAL_SOURCE_WP_TITLES:
predefinedSourceHelper.getAnswerFromWP(intent.externalAnswerSource).then(answer=>{
answerPromiseProps.resolve(answer);
}).catch(error=>{
answerPromiseProps.reject(error);
});
break;
case constants.answerType.EXTERNAL_SOURCE_RSS:
case constants.answerType.EXTERNAL_SOURCE_WP_NEWS:
answer = 'Not implemented yet'
answerPromiseProps.resolve(answer);
break;
}
answer.then(answer=>{
this.response
.speak (answer)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
this.emit (':responseReady');
}).catch(error=>{
this.response
.speak (error)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
this.emit (':responseReady');
});
answerPromise
.then (answer => {
this.response
.speak (answer)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
this.emit (':responseReady');
})
.catch (error => {
this.response
.speak (error)
.listen (constants.voiceResponseStrings.GENERIC_CONTINUE); //Phrase from listen doesn't work !!!
this.emit (':responseReady');
});
};
});
@@ -213,7 +217,7 @@ module.exports = {
if (this.attributes['LaunchRequestYesNo']) {
this.attributes['LaunchRequestYesNo'] = false;
}
this.response.speak ('Thank you for using Saburly');
this.response.speak (`Thank you for using ${skillName}`);
this.emit (':responseReady');
};