From d6f4639077c75224280996c3b3378829acaa9c0a Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Fri, 31 Dec 2021 09:39:23 -0300 Subject: [PATCH] fix(basic.gblib): Username was not being retrived. --- packages/basic.gblib/services/DialogKeywords.ts | 3 ++- packages/whatsapp.gblib/services/WhatsappDirectLine.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 2ea0b90ff..9138cbd78 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -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'; } /** diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 424595720..fb70b45c3 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -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);