From 3eb8d0a53f28b81556dd849690298f59b7759c8f Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Thu, 26 Nov 2020 10:47:35 -0300 Subject: [PATCH] fix(all): Language and Spellchecker are now modern. --- .../services/GBConversationalService.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/core.gbapp/services/GBConversationalService.ts b/packages/core.gbapp/services/GBConversationalService.ts index b3a2aea0..97f0d1c4 100644 --- a/packages/core.gbapp/services/GBConversationalService.ts +++ b/packages/core.gbapp/services/GBConversationalService.ts @@ -209,7 +209,7 @@ export class GBConversationalService { return new Promise(async (resolve, reject) => { try { const oggFile = new Readable(); - oggFile._read = () => {}; // _read is required but you can noop it + oggFile._read = () => { }; // _read is required but you can noop it oggFile.push(buffer); oggFile.push(null); @@ -485,9 +485,8 @@ export class GBConversationalService { return false; } else { - const msg = `Error calling NLP, check if you have a published model and assigned keys. Error: ${ - error.statusCode ? error.statusCode : '' - } {error.message; }`; + const msg = `Error calling NLP, check if you have a published model and assigned keys. Error: ${error.statusCode ? error.statusCode : '' + } {error.message; }`; throw new Error(msg); } @@ -534,17 +533,19 @@ export class GBConversationalService { public async getLanguage(min: GBMinInstance, text: string): Promise { return await AzureText.getLocale( - min.instance.textAnalyticsKey ? min.instance.textAnalyticsKey : min.instance.textAnalyticsKey, - min.instance.textAnalyticsEndpoint ? min.instance.textAnalyticsEndpoint : min.instance.textAnalyticsEndpoint, + min.core.getParam(min.instance, 'textAnalyticsKey', null), + min.core.getParam(min.instance, 'textAnalyticsEndpoint', null), text ); } public async spellCheck(min: GBMinInstance, text: string): Promise { - const key = min.instance.spellcheckerKey ? min.instance.spellcheckerKey : min.instance.spellcheckerKey; + const key = + min.core.getParam(min.instance, 'spellcheckerKey', null); + if (key) { text = text.charAt(0).toUpperCase() + text.slice(1); - const data = await AzureText.getSpelledText(min.instance.spellcheckerKey, text); + const data = await AzureText.getSpelledText(key, text); if (data !== text) { GBLog.info(`Spelling corrected (processMessageActivity): ${data}`); text = data; @@ -640,7 +641,7 @@ export class GBConversationalService { GBLog.info(`Translated text(sendText): ${text}.`); const analytics = new AnalyticsService(); - + analytics.createMessage(min.instance.instanceId, user.conversation, null, text); if (!isNaN(member.id)) {