@twentyhq/teams 1.1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dependencies/yarn.lock +723 -3
- package/manifest.json +46 -29
- package/package.json +4 -2
- package/src/features/chat/logic-functions/teams-activities-enqueue.mjs +378 -162
- package/src/features/chat/logic-functions/teams-activities-enqueue.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-activities-enqueue.ts +1 -1
- package/src/features/chat/logic-functions/teams-activities-resolver.mjs +500 -40
- package/src/features/chat/logic-functions/teams-activities-resolver.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-activities-resolver.ts +13 -2
- package/src/features/chat/logic-functions/teams-list-unlinked-users.mjs +95 -61
- package/src/features/chat/logic-functions/teams-list-unlinked-users.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-match-user-links.mjs +105 -86
- package/src/features/chat/logic-functions/teams-match-user-links.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-register-connection.mjs +119 -101
- package/src/features/chat/logic-functions/teams-register-connection.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-register-connection.ts +1 -1
- package/src/features/chat/logic-functions/teams-search-users.mjs +96 -62
- package/src/features/chat/logic-functions/teams-search-users.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-set-user-link.mjs +88 -54
- package/src/features/chat/logic-functions/teams-set-user-link.mjs.map +4 -4
- package/src/features/chat/logic-functions/teams-tenant-release.mjs +72 -41
- package/src/features/chat/logic-functions/teams-tenant-release.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-count-transcript-history.mjs +99 -68
- package/src/features/transcripts/logic-functions/teams-count-transcript-history.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-import-transcript-history.mjs +99 -68
- package/src/features/transcripts/logic-functions/teams-import-transcript-history.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-import-transcript.mjs +96 -65
- package/src/features/transcripts/logic-functions/teams-import-transcript.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-list-organizer-transcripts.mjs +89 -58
- package/src/features/transcripts/logic-functions/teams-list-organizer-transcripts.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-sync-transcript.mjs +96 -65
- package/src/features/transcripts/logic-functions/teams-sync-transcript.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-transcript-history-count.mjs +0 -1
- package/src/features/transcripts/logic-functions/teams-transcript-history-count.mjs.map +2 -2
- package/src/features/transcripts/logic-functions/teams-transcript-history-import.mjs +0 -1
- package/src/features/transcripts/logic-functions/teams-transcript-history-import.mjs.map +2 -2
- package/src/features/transcripts/logic-functions/teams-transcript-history-status.mjs +0 -1
- package/src/features/transcripts/logic-functions/teams-transcript-history-status.mjs.map +2 -2
- package/src/features/transcripts/logic-functions/teams-transcripts-webhook.mjs +104 -73
- package/src/features/transcripts/logic-functions/teams-transcripts-webhook.mjs.map +4 -4
- package/src/features/transcripts/logic-functions/teams-uninstall.mjs +72 -41
- package/src/features/transcripts/logic-functions/teams-uninstall.mjs.map +4 -4
- package/src/front-components/settings.front-component.mjs +113 -113
- package/src/front-components/settings.front-component.mjs.map +4 -4
- package/src/logic-functions/teams-health-check.mjs +46 -25
- package/src/logic-functions/teams-health-check.mjs.map +4 -4
- package/src/logic-functions/teams-health-check.ts +21 -6
- package/src/logic-functions/teams-post-install.mjs +1270 -0
- package/src/logic-functions/teams-post-install.mjs.map +7 -0
- package/src/logic-functions/teams-post-install.ts +15 -0
|
@@ -10,11 +10,15 @@ import {
|
|
|
10
10
|
TEAMS_ACTIVITIES_ENQUEUE_UNIVERSAL_IDENTIFIER,
|
|
11
11
|
TEAMS_ACTIVITIES_ROUTE_UNIVERSAL_IDENTIFIER,
|
|
12
12
|
} from 'src/features/chat/constants/universal-identifiers';
|
|
13
|
+
import { TEAMS_ASSISTANT_NOT_CONNECTED_TEXT } from 'src/features/chat/logic-functions/constants/teams-assistant-not-connected-text';
|
|
14
|
+
import { TEAMS_ASSISTANT_NOTICE_TTL_MS } from 'src/features/chat/logic-functions/constants/teams-assistant-notice-ttl-ms';
|
|
13
15
|
import { type TeamsActivitiesDispatchPayload } from 'src/features/chat/logic-functions/types/teams-activities-dispatch-payload.type';
|
|
14
16
|
import { TeamsActivityTokenInvalidError } from 'src/features/chat/logic-functions/types/teams-activity-token-invalid-error';
|
|
15
17
|
import { type TeamsInboundActivity } from 'src/features/chat/logic-functions/types/teams-inbound-activity.type';
|
|
16
18
|
import { buildTeamsTenantKvKey } from 'src/features/chat/logic-functions/utils/build-teams-tenant-kv-key';
|
|
17
19
|
import { getTeamsBotCredentials } from 'src/features/chat/logic-functions/utils/get-teams-bot-credentials';
|
|
20
|
+
import { isTeamsInstallActivity } from 'src/features/chat/logic-functions/utils/is-teams-install-activity';
|
|
21
|
+
import { sendTeamsAssistantNotice } from 'src/features/chat/logic-functions/utils/send-teams-assistant-notice';
|
|
18
22
|
import { verifyTeamsActivityTokenOrThrow } from 'src/features/chat/logic-functions/utils/verify-teams-activity-token';
|
|
19
23
|
|
|
20
24
|
export const teamsActivitiesResolverHandler = async (
|
|
@@ -48,7 +52,7 @@ export const teamsActivitiesResolverHandler = async (
|
|
|
48
52
|
return new Response({ error: 'Unauthorized' }, { status: 401 });
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
if (activity.type !== 'message') {
|
|
55
|
+
if (activity.type !== 'message' && !isTeamsInstallActivity(activity)) {
|
|
52
56
|
return new Response({ ok: true, skipped: 'Not a message' });
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -64,6 +68,13 @@ export const teamsActivitiesResolverHandler = async (
|
|
|
64
68
|
});
|
|
65
69
|
|
|
66
70
|
if (!isNonEmptyString(workspaceId)) {
|
|
71
|
+
await sendTeamsAssistantNotice({
|
|
72
|
+
payload: { activity, serviceUrl, tenantId },
|
|
73
|
+
kind: 'not-connected',
|
|
74
|
+
text: TEAMS_ASSISTANT_NOT_CONNECTED_TEXT,
|
|
75
|
+
ttlMs: TEAMS_ASSISTANT_NOTICE_TTL_MS,
|
|
76
|
+
});
|
|
77
|
+
|
|
67
78
|
return new Response({
|
|
68
79
|
ok: true,
|
|
69
80
|
skipped: 'No workspace claims this Teams tenant',
|
|
@@ -86,7 +97,7 @@ export default defineLogicFunction({
|
|
|
86
97
|
universalIdentifier: TEAMS_ACTIVITIES_ROUTE_UNIVERSAL_IDENTIFIER,
|
|
87
98
|
name: 'teams-activities-resolver',
|
|
88
99
|
description:
|
|
89
|
-
'Receives Microsoft Teams bot activities, verifies the Bot Framework token, and routes message activities to the workspace that claimed their tenant.',
|
|
100
|
+
'Receives Microsoft Teams bot activities, verifies the Bot Framework token, and routes message and install activities to the workspace that claimed their tenant. When no workspace claims the tenant, tells the conversation once an hour that Twenty is not connected.',
|
|
90
101
|
timeoutSeconds: 15,
|
|
91
102
|
handler: teamsActivitiesResolverHandler,
|
|
92
103
|
serverRouteTriggerSettings: {
|
|
@@ -124,10 +124,10 @@ var require_convenience = __commonJS({
|
|
|
124
124
|
return structural_1.isArray(term) && term.length > 0;
|
|
125
125
|
};
|
|
126
126
|
exports.isNonEmptyArray = isNonEmptyArray2;
|
|
127
|
-
var
|
|
127
|
+
var isNonEmptyString9 = (term) => {
|
|
128
128
|
return primitives_1.isString(term) && term.length > 0;
|
|
129
129
|
};
|
|
130
|
-
exports.isNonEmptyString =
|
|
130
|
+
exports.isNonEmptyString = isNonEmptyString9;
|
|
131
131
|
var isNumberOrNaN = (term) => {
|
|
132
132
|
return typeof term === "number";
|
|
133
133
|
};
|
|
@@ -261,14 +261,14 @@ var listLinkedTeamsUserAadObjectIdsOrThrow = async ({
|
|
|
261
261
|
};
|
|
262
262
|
|
|
263
263
|
// src/features/chat/logic-functions/utils/collect-graph-users.ts
|
|
264
|
-
var
|
|
264
|
+
var import_guards6 = __toESM(require_build());
|
|
265
265
|
|
|
266
266
|
// node_modules/twenty-sdk/dist/utils/index.mjs
|
|
267
267
|
var import_guards2 = __toESM(require_build(), 1);
|
|
268
268
|
var o = (n2) => !(0, import_guards2.isUndefined)(n2) && !(0, import_guards2.isNull)(n2);
|
|
269
269
|
|
|
270
270
|
// src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
|
|
271
|
-
var
|
|
271
|
+
var import_guards4 = __toESM(require_build());
|
|
272
272
|
|
|
273
273
|
// src/features/transcripts/logic-functions/constants/graph-request-max-attempts.ts
|
|
274
274
|
var GRAPH_REQUEST_MAX_ATTEMPTS = 4;
|
|
@@ -305,62 +305,93 @@ var resolveGraphUrlOrThrow = (url) => {
|
|
|
305
305
|
return resolvedUrl.toString();
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
-
// src/
|
|
308
|
+
// src/utils/parse-retry-after-ms.ts
|
|
309
|
+
var import_guards3 = __toESM(require_build());
|
|
310
|
+
var parseRetryAfterMs = (retryAfter) => {
|
|
311
|
+
if (!(0, import_guards3.isNonEmptyString)(retryAfter)) {
|
|
312
|
+
return void 0;
|
|
313
|
+
}
|
|
314
|
+
const retryAfterSeconds = Number(retryAfter);
|
|
315
|
+
if (Number.isFinite(retryAfterSeconds)) {
|
|
316
|
+
return Math.max(retryAfterSeconds * 1e3, 0);
|
|
317
|
+
}
|
|
318
|
+
const retryAtMs = Date.parse(retryAfter);
|
|
319
|
+
return Number.isNaN(retryAtMs) ? void 0 : Math.max(retryAtMs - Date.now(), 0);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/utils/sleep-for-milliseconds.ts
|
|
309
323
|
var sleepForMilliseconds = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
310
324
|
|
|
325
|
+
// src/utils/fetch-with-retries.ts
|
|
326
|
+
var fetchWithRetries = async ({
|
|
327
|
+
sendRequest,
|
|
328
|
+
maxAttempts,
|
|
329
|
+
isRetryableStatus,
|
|
330
|
+
getRetryDelayMs,
|
|
331
|
+
retryAbortSignal
|
|
332
|
+
}) => {
|
|
333
|
+
const sendAttempt = async ({
|
|
334
|
+
attempt,
|
|
335
|
+
waitedMs
|
|
336
|
+
}) => {
|
|
337
|
+
const response = await sendRequest();
|
|
338
|
+
if (response.ok || !isRetryableStatus(response.status) || attempt + 1 >= maxAttempts) {
|
|
339
|
+
return response;
|
|
340
|
+
}
|
|
341
|
+
const delayMs = getRetryDelayMs({
|
|
342
|
+
attempt,
|
|
343
|
+
retryAfterMs: parseRetryAfterMs(response.headers.get("retry-after")),
|
|
344
|
+
waitedMs
|
|
345
|
+
});
|
|
346
|
+
if (!o(delayMs)) {
|
|
347
|
+
return response;
|
|
348
|
+
}
|
|
349
|
+
await sleepForMilliseconds(delayMs);
|
|
350
|
+
if (o(retryAbortSignal) && retryAbortSignal.aborted) {
|
|
351
|
+
return response;
|
|
352
|
+
}
|
|
353
|
+
await response.body?.cancel();
|
|
354
|
+
return sendAttempt({ attempt: attempt + 1, waitedMs: waitedMs + delayMs });
|
|
355
|
+
};
|
|
356
|
+
return sendAttempt({ attempt: 0, waitedMs: 0 });
|
|
357
|
+
};
|
|
358
|
+
|
|
311
359
|
// src/features/transcripts/logic-functions/utils/fetch-graph-response.ts
|
|
312
|
-
var
|
|
360
|
+
var fetchGraphResponse = async ({
|
|
313
361
|
accessToken,
|
|
314
362
|
url,
|
|
315
363
|
accept,
|
|
316
364
|
method,
|
|
317
|
-
body
|
|
318
|
-
attempt
|
|
365
|
+
body
|
|
319
366
|
}) => {
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
367
|
+
const resolvedUrl = resolveGraphUrlOrThrow(url);
|
|
368
|
+
const response = await fetchWithRetries({
|
|
369
|
+
sendRequest: () => fetch(resolvedUrl, {
|
|
370
|
+
method,
|
|
371
|
+
redirect: "error",
|
|
372
|
+
headers: {
|
|
373
|
+
Authorization: `Bearer ${accessToken}`,
|
|
374
|
+
Accept: accept,
|
|
375
|
+
...o(body) ? { "Content-Type": "application/json" } : {}
|
|
376
|
+
},
|
|
377
|
+
body: o(body) ? JSON.stringify(body) : void 0
|
|
378
|
+
}),
|
|
379
|
+
maxAttempts: GRAPH_REQUEST_MAX_ATTEMPTS,
|
|
380
|
+
isRetryableStatus: (status) => GRAPH_RETRYABLE_STATUSES.has(status),
|
|
381
|
+
getRetryDelayMs: ({ attempt, retryAfterMs }) => o(retryAfterMs) && retryAfterMs > 0 ? retryAfterMs : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
|
|
329
382
|
});
|
|
330
383
|
if (response.ok) {
|
|
331
384
|
return response;
|
|
332
385
|
}
|
|
333
|
-
if (GRAPH_RETRYABLE_STATUSES.has(response.status) && attempt + 1 < GRAPH_REQUEST_MAX_ATTEMPTS) {
|
|
334
|
-
const retryAfterSeconds = Number(response.headers.get("Retry-After"));
|
|
335
|
-
await sleepForMilliseconds(
|
|
336
|
-
retryAfterSeconds > 0 ? retryAfterSeconds * 1e3 : GRAPH_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt
|
|
337
|
-
);
|
|
338
|
-
return fetchGraphResponseWithRetries({
|
|
339
|
-
accessToken,
|
|
340
|
-
url,
|
|
341
|
-
accept,
|
|
342
|
-
method,
|
|
343
|
-
body,
|
|
344
|
-
attempt: attempt + 1
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
386
|
const errorBody = await response.json().catch(() => ({}));
|
|
348
|
-
const innerErrorCode = (0,
|
|
349
|
-
const message = (0,
|
|
387
|
+
const innerErrorCode = (0, import_guards4.isNonEmptyString)(errorBody.error?.innerError?.code) ? errorBody.error.innerError.code : void 0;
|
|
388
|
+
const message = (0, import_guards4.isNonEmptyString)(errorBody.error?.message) ? errorBody.error.message : response.statusText;
|
|
350
389
|
throw new GraphRequestError({
|
|
351
|
-
message: `Microsoft Graph request failed (${response.status}${(0,
|
|
390
|
+
message: `Microsoft Graph request failed (${response.status}${(0, import_guards4.isNonEmptyString)(innerErrorCode) ? ` ${innerErrorCode}` : ""}): ${message}`,
|
|
352
391
|
status: response.status,
|
|
353
392
|
innerErrorCode
|
|
354
393
|
});
|
|
355
394
|
};
|
|
356
|
-
var fetchGraphResponse = ({
|
|
357
|
-
url,
|
|
358
|
-
...request
|
|
359
|
-
}) => fetchGraphResponseWithRetries({
|
|
360
|
-
...request,
|
|
361
|
-
url: resolveGraphUrlOrThrow(url),
|
|
362
|
-
attempt: 0
|
|
363
|
-
});
|
|
364
395
|
|
|
365
396
|
// src/features/transcripts/logic-functions/utils/fetch-graph-json.ts
|
|
366
397
|
var fetchGraphJson = async ({
|
|
@@ -381,8 +412,8 @@ var fetchGraphJson = async ({
|
|
|
381
412
|
};
|
|
382
413
|
|
|
383
414
|
// src/features/chat/logic-functions/utils/is-linkable-graph-user.ts
|
|
384
|
-
var
|
|
385
|
-
var isLinkableGraphUser = (user) => (0,
|
|
415
|
+
var import_guards5 = __toESM(require_build());
|
|
416
|
+
var isLinkableGraphUser = (user) => (0, import_guards5.isNonEmptyString)(user.id) && ((0, import_guards5.isNonEmptyString)(user.mail) || (0, import_guards5.isNonEmptyString)(user.userPrincipalName));
|
|
386
417
|
|
|
387
418
|
// src/features/chat/logic-functions/utils/collect-graph-users.ts
|
|
388
419
|
var DEFAULT_MAX_PAGES = 5;
|
|
@@ -397,7 +428,7 @@ var collectGraphUsers = async ({
|
|
|
397
428
|
const seenAadObjectIds = /* @__PURE__ */ new Set();
|
|
398
429
|
let nextUrl = url;
|
|
399
430
|
for (let page = 0; page < maxPages; page += 1) {
|
|
400
|
-
if (!(0,
|
|
431
|
+
if (!(0, import_guards6.isNonEmptyString)(nextUrl)) {
|
|
401
432
|
return { users, isTruncated: false };
|
|
402
433
|
}
|
|
403
434
|
const pageResult = await fetchGraphJson({
|
|
@@ -419,10 +450,10 @@ var collectGraphUsers = async ({
|
|
|
419
450
|
users.push(user);
|
|
420
451
|
}
|
|
421
452
|
if (o(maxUsers) && users.length >= maxUsers) {
|
|
422
|
-
return { users, isTruncated: (0,
|
|
453
|
+
return { users, isTruncated: (0, import_guards6.isNonEmptyString)(nextUrl) };
|
|
423
454
|
}
|
|
424
455
|
}
|
|
425
|
-
return { users, isTruncated: (0,
|
|
456
|
+
return { users, isTruncated: (0, import_guards6.isNonEmptyString)(nextUrl) };
|
|
426
457
|
};
|
|
427
458
|
|
|
428
459
|
// src/features/chat/logic-functions/utils/current-user-has-roles-permission.ts
|
|
@@ -445,12 +476,12 @@ var currentUserHasRolesPermission = async () => {
|
|
|
445
476
|
};
|
|
446
477
|
|
|
447
478
|
// src/features/chat/logic-functions/utils/get-teams-workspace-graph-access.ts
|
|
448
|
-
var
|
|
479
|
+
var import_guards9 = __toESM(require_build());
|
|
449
480
|
|
|
450
481
|
// node_modules/twenty-sdk/dist/logic-function/index.mjs
|
|
451
|
-
var
|
|
482
|
+
var import_guards7 = __toESM(require_build(), 1);
|
|
452
483
|
import { MetadataApiClient as a } from "twenty-client-sdk/metadata";
|
|
453
|
-
var s = (e3) => !(0,
|
|
484
|
+
var s = (e3) => !(0, import_guards7.isUndefined)(e3) && !(0, import_guards7.isNull)(e3);
|
|
454
485
|
var c = (t3) => {
|
|
455
486
|
let n2 = { type: "unknown" };
|
|
456
487
|
switch (t3.type) {
|
|
@@ -479,7 +510,7 @@ var c = (t3) => {
|
|
|
479
510
|
default:
|
|
480
511
|
n2.type = "unknown";
|
|
481
512
|
}
|
|
482
|
-
return Array.isArray(t3.enum) && (n2.enum = t3.enum.filter((e3) => typeof e3 == "string")), t3.multiline === true && (n2.multiline = true), (0,
|
|
513
|
+
return Array.isArray(t3.enum) && (n2.enum = t3.enum.filter((e3) => typeof e3 == "string")), t3.multiline === true && (n2.multiline = true), (0, import_guards7.isNonEmptyString)(t3.label) && (n2.label = t3.label), (0, import_guards7.isNonEmptyString)(t3.objectUniversalIdentifier) && (n2.objectUniversalIdentifier = t3.objectUniversalIdentifier), n2;
|
|
483
514
|
};
|
|
484
515
|
var l = (e3) => [c(e3)];
|
|
485
516
|
l({
|
|
@@ -634,19 +665,22 @@ var TEAMS_CONNECTED_ACCOUNT_TENANT_KV_KEY_PREFIX = "teams-connected-account-tena
|
|
|
634
665
|
var buildTeamsConnectedAccountTenantKvKey = (connectedAccountId) => `${TEAMS_CONNECTED_ACCOUNT_TENANT_KV_KEY_PREFIX}:${connectedAccountId}`;
|
|
635
666
|
|
|
636
667
|
// src/features/chat/logic-functions/utils/fetch-teams-tenant-id.ts
|
|
637
|
-
var
|
|
668
|
+
var import_guards8 = __toESM(require_build());
|
|
638
669
|
var fetchTeamsTenantId = async (accessToken) => {
|
|
639
670
|
const page = await fetchGraphJson({
|
|
640
671
|
accessToken,
|
|
641
672
|
url: "organization?$select=id"
|
|
642
673
|
});
|
|
643
674
|
const tenantId = page.value?.[0]?.id;
|
|
644
|
-
if (!(0,
|
|
675
|
+
if (!(0, import_guards8.isNonEmptyString)(tenantId)) {
|
|
645
676
|
throw new Error("Microsoft Graph returned no organization to claim");
|
|
646
677
|
}
|
|
647
678
|
return tenantId;
|
|
648
679
|
};
|
|
649
680
|
|
|
681
|
+
// src/features/chat/logic-functions/utils/is-working-teams-workspace-connection.ts
|
|
682
|
+
var isWorkingTeamsWorkspaceConnection = (connection) => connection.scope === "WORKSPACE" && !o(connection.authFailedAt);
|
|
683
|
+
|
|
650
684
|
// src/features/transcripts/constants/teams-oauth-config.ts
|
|
651
685
|
var TEAMS_GRAPH_DIRECTORY_SCOPE = "https://graph.microsoft.com/User.ReadBasic.All";
|
|
652
686
|
|
|
@@ -685,9 +719,9 @@ var getTeamsWorkspaceGraphAccess = async () => {
|
|
|
685
719
|
try {
|
|
686
720
|
const connections = await listTeamsConnections();
|
|
687
721
|
const workspaceConnections = connections.filter(
|
|
688
|
-
|
|
722
|
+
isWorkingTeamsWorkspaceConnection
|
|
689
723
|
);
|
|
690
|
-
if (!(0,
|
|
724
|
+
if (!(0, import_guards9.isNonEmptyArray)(workspaceConnections)) {
|
|
691
725
|
return { success: false, error: NOT_CONNECTED_ERROR_MESSAGE };
|
|
692
726
|
}
|
|
693
727
|
const connection = workspaceConnections.find(
|
|
@@ -700,7 +734,7 @@ var getTeamsWorkspaceGraphAccess = async () => {
|
|
|
700
734
|
const storedTenantId = await ge.get(
|
|
701
735
|
buildTeamsConnectedAccountTenantKvKey(connection.id)
|
|
702
736
|
);
|
|
703
|
-
const tenantId = (0,
|
|
737
|
+
const tenantId = (0, import_guards9.isNonEmptyString)(storedTenantId) ? storedTenantId : await fetchTeamsTenantId(accessToken);
|
|
704
738
|
return { success: true, accessToken, tenantId };
|
|
705
739
|
} catch (error) {
|
|
706
740
|
return { success: false, error: toErrorMessage(error) };
|
|
@@ -708,7 +742,7 @@ var getTeamsWorkspaceGraphAccess = async () => {
|
|
|
708
742
|
};
|
|
709
743
|
|
|
710
744
|
// src/features/chat/logic-functions/utils/read-teams-directory-match-run-outcome.ts
|
|
711
|
-
var
|
|
745
|
+
var import_guards10 = __toESM(require_build());
|
|
712
746
|
|
|
713
747
|
// src/features/chat/logic-functions/constants/teams-directory-match-run-outcome-kv-key.ts
|
|
714
748
|
var TEAMS_DIRECTORY_MATCH_RUN_OUTCOME_KV_KEY = "teams-directory-match-run-outcome";
|
|
@@ -719,7 +753,7 @@ var readTeamsDirectoryMatchRunOutcome = async () => {
|
|
|
719
753
|
const record = await ge.get(
|
|
720
754
|
TEAMS_DIRECTORY_MATCH_RUN_OUTCOME_KV_KEY
|
|
721
755
|
);
|
|
722
|
-
return (0,
|
|
756
|
+
return (0, import_guards10.isBoolean)(record?.isSuccessful) ? { isSuccessful: record.isSuccessful, errorMessage: record.errorMessage } : void 0;
|
|
723
757
|
} catch {
|
|
724
758
|
return void 0;
|
|
725
759
|
}
|
|
@@ -729,11 +763,11 @@ var readTeamsDirectoryMatchRunOutcome = async () => {
|
|
|
729
763
|
var toTeamsGraphUsersErrorMessage = (error) => error instanceof GraphRequestError && error.status === 403 ? "Microsoft did not allow reading the organization directory. Reconnect Microsoft Teams from the app settings to grant directory access, or ask a tenant administrator to allow it." : toErrorMessage(error);
|
|
730
764
|
|
|
731
765
|
// src/features/chat/logic-functions/utils/to-teams-user-search-option.ts
|
|
732
|
-
var
|
|
766
|
+
var import_guards11 = __toESM(require_build());
|
|
733
767
|
var toTeamsUserSearchOption = (user) => ({
|
|
734
768
|
teamsUserAadObjectId: user.id,
|
|
735
|
-
displayName: (0,
|
|
736
|
-
email: (0,
|
|
769
|
+
displayName: (0, import_guards11.isNonEmptyString)(user.displayName) ? user.displayName : void 0,
|
|
770
|
+
email: (0, import_guards11.isNonEmptyString)(user.mail) ? user.mail : user.userPrincipalName
|
|
737
771
|
});
|
|
738
772
|
|
|
739
773
|
// src/features/chat/logic-functions/handlers/teams-list-unlinked-users-handler.ts
|