Skip to content

Commit

Permalink
fix(basic.gblib): Username was not being retrived.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Dec 31, 2021
1 parent abe4281 commit 0335b71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/basic.gblib/services/DialogKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');


Expand Down Expand Up @@ -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';
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0335b71

Please sign in to comment.