fix(all): Locale in Audio is dynamic.

This commit is contained in:
Rodrigo Rodriguez 2024-02-17 22:21:40 -03:00
parent d1c4c23fa1
commit fb6e57b19a
3 changed files with 25 additions and 24 deletions

File diff suppressed because one or more lines are too long

View file

@ -543,7 +543,7 @@ export class GBConversationalService {
const languageCode = locale.substring(0, 2);
return locales[languageCode] || "en-US_BroadbandModel";
};
};
public async playMarkdown(min: GBMinInstance, answer: string, channel: string,
@ -1006,10 +1006,10 @@ export class GBConversationalService {
let results = await fetch(url, options);
results = await results.json();
if (results[0]){
if (results[0]) {
return results[0].translations[0].text;
}
else{
else {
return text;
}
} catch (error) {
@ -1097,7 +1097,7 @@ export class GBConversationalService {
// Detects user typed language and updates their locale profile if applies.
let locale = min.core.getParam(
let locale = user.locale ? user.locale : min.core.getParam(
min.instance,
'Default User Language',
GBConfigService.get('DEFAULT_USER_LANGUAGE'));

View file

@ -958,10 +958,7 @@ export class WhatsappDirectLine extends GBService {
private async WhatsAppCallback(req, res) {
try {
if (req.body && req.body.webhook) {
res.status(200);
res.end();
if (!req.body) {
return;
}
@ -1068,8 +1065,10 @@ export class WhatsappDirectLine extends GBService {
user = await sec.ensureUser(urlMin, id, '', '', 'omnichannel', '', '');
user = await sec.updateUserInstance(id, urlMin.instance.instanceId);
if (locale){
user = await sec.updateUserLocale(user.userId, locale);
}
}
let activeMin;