fix(basic.gblib): Username was not being retrived.

This commit is contained in:
Rodrigo Rodriguez 2021-12-31 09:39:23 -03:00
parent abe4281b73
commit 0335b715cd
2 changed files with 5 additions and 1 deletions

View file

@ -41,6 +41,7 @@ import { SecService } from '../../security.gbapp/services/SecService';
import { SystemKeywords } from './SystemKeywords';
import { GBMinService } from '../../core.gbapp/services/GBMinService';
import { HubSpotServices } from '../../hubspot.gblib/services/HubSpotServices';
import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine';
var DateDiff = require('date-diff');
@ -414,7 +415,7 @@ export class DialogKeywords {
* Returns the name of the user acquired by WhatsApp API.
*/
public async userName(step) {
return step ? step.context.activity.from.name : 'N/A';
return step ? WhatsappDirectLine.usernames[await this.userMobile(step)] : 'N/A';
}
/**

View file

@ -51,6 +51,7 @@ export class WhatsappDirectLine extends GBService {
public static conversationIds = {};
public static mobiles = {};
public static chatIds = {};
public static usernames = {};
public pollInterval = 3000;
public directLineClientName = 'DirectLineClient';
@ -371,7 +372,9 @@ export class WhatsappDirectLine extends GBService {
WhatsappDirectLine.conversationIds[from + group] = generatedConversationId;
WhatsappDirectLine.mobiles[generatedConversationId] = from;
WhatsappDirectLine.usernames[from] = fromName;
WhatsappDirectLine.chatIds[generatedConversationId] = message.chatId;
this.pollMessages(client, generatedConversationId, from, fromName);
this.inputMessage(client, generatedConversationId, text, from, fromName, group);