Skip to content

Commit

Permalink
Setting conversation id on the TokenExchangeState (#467)
Browse files Browse the repository at this point in the history
This is needed to talk back to the emulator and identify
the converstation
  • Loading branch information
Jeffders committed May 3, 2018
1 parent aa6c640 commit 30cd14b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class ConversationsController {
log.api(`Reply[${activity.type}]`, req, res, activity, response, getActivityText(activity));
};

let visitor = new OAuthLinkEncoder(emulator.framework.getNgrokServiceUrl(), req.headers['authorization'], activity);
let visitor = new OAuthLinkEncoder(emulator.framework.getNgrokServiceUrl(), req.headers['authorization'], activity, parms.conversationId);
visitor.resolveOAuthCards(activity).then((value?: any) =>
{
continuation();
Expand Down
8 changes: 5 additions & 3 deletions src/shared/oauthLinkEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ export class OAuthLinkEncoder {
private emulatorUrl: string;
private authorizationHeader: string;
private activity: IGenericActivity;
private conversationId: string;

constructor(emulatorUrl: string, authorizationHeader: string, activity: IGenericActivity) {
constructor(emulatorUrl: string, authorizationHeader: string, activity: IGenericActivity, conversationId: string) {
this.emulatorUrl = emulatorUrl;
this.authorizationHeader = authorizationHeader;
this.activity = activity;
this.conversationId = conversationId;
}

public resolveOAuthCards(activity: IGenericActivity): Promise<any> {
Expand Down Expand Up @@ -120,8 +122,8 @@ export class OAuthLinkEncoder {
{
ActivityId: this.activity.id,
Bot: this.activity.from, // Activity is from the bot to the user
ChannelId: this.activity.channelId,
Conversation: this.activity.conversation,
ChannelId: this.activity.channelId ? this.activity.channelId : 'emulator',
Conversation: this.activity.conversation ? this.activity.conversation : { id: this.conversationId },
ServiceUrl: this.activity.serviceUrl,
User: this.activity.recipient
}
Expand Down

0 comments on commit 30cd14b

Please sign in to comment.