Skip to content

Commit

Permalink
fix(all): Minor changes in PROD.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Aug 1, 2023
1 parent 4f89800 commit 76c1efd
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1198,8 +1198,37 @@ export class GBMinService {
context.activity.text = context.activity.text.trim();

const member = context.activity.from;
let memberId, email;

// Processes e-mail from id in case of Teams messages.

let user = await sec.ensureUser(min.instance.instanceId, member.id, member.name, '', 'web', member.name, null);
if (member.id.startsWith("29:")){
const token = await (min.adminService as any)
['acquireElevatedToken'](min.instance.instanceId, false);

const url = `https://graph.microsoft.com/v1.0/users/${context.activity.from.aadObjectId}`;
const options = {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`
}
};

try {
const res = await fetch(url, options);
const member = JSON.parse(await res.text());
memberId = member.mail;
email = member.mail;
} catch (error) {
throw `[botId:${min.instance.botId}] Error calling Teams to get user info: ${error}.`;
}
}
else
{
memberId = member.id;
}

let user = await sec.ensureUser(min.instance.instanceId, memberId, member.name, '', 'web', member.name, email);

const userId = user.userId;
const params = user.params ? JSON.parse(user.params) : {};
Expand Down

0 comments on commit 76c1efd

Please sign in to comment.