@oneuptime/common 8.0.5347 → 8.0.5354
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/Server/API/MicrosoftTeamsAPI.ts +100 -98
- package/Server/Images/MicrosoftTeams/outline.png +0 -0
- package/Server/Services/UserNotificationRuleService.ts +8 -4
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +147 -12
- package/build/dist/Server/API/MicrosoftTeamsAPI.js +10 -4
- package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/Services/UserNotificationRuleService.js +4 -4
- package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +136 -10
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/package.json +1 -1
|
@@ -58,7 +58,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
58
58
|
"https://developer.microsoft.com/json-schemas/teams/v1.23/MicrosoftTeams.schema.json",
|
|
59
59
|
manifestVersion: "1.23",
|
|
60
60
|
version: AppVersion.toLowerCase().includes("unknown")
|
|
61
|
-
? "1.
|
|
61
|
+
? "1.3.0"
|
|
62
62
|
: AppVersion,
|
|
63
63
|
id: MicrosoftTeamsAppClientId,
|
|
64
64
|
developer: {
|
|
@@ -66,16 +66,22 @@ export default class MicrosoftTeamsAPI {
|
|
|
66
66
|
websiteUrl: "https://oneuptime.com",
|
|
67
67
|
privacyUrl: "https://oneuptime.com/legal/privacy",
|
|
68
68
|
termsOfUseUrl: "https://oneuptime.com/legal/terms",
|
|
69
|
-
publisherDocsUrl:
|
|
70
|
-
"https://oneuptime.com/docs/workspace-connections/microsoft-teams",
|
|
71
69
|
},
|
|
70
|
+
publisherDocsUrl:
|
|
71
|
+
"https://oneuptime.com/docs/workspace-connections/microsoft-teams",
|
|
72
72
|
name: {
|
|
73
73
|
short: "OneUptime",
|
|
74
74
|
full: "OneUptime - Complete Observability Platform",
|
|
75
75
|
},
|
|
76
76
|
description: {
|
|
77
|
-
short: "
|
|
78
|
-
full:
|
|
77
|
+
short: "Complete open-source monitoring and observability platform. ",
|
|
78
|
+
full: `OneUptime is a comprehensive solution for monitoring and managing your online services. Whether you need to check the availability of your website, dashboard, API, or any other online resource, OneUptime can alert your team when downtime happens and keep your customers informed with a status page. OneUptime also helps you handle incidents, set up on-call rotations, run tests, secure your services, analyze logs, track performance, and debug errors.
|
|
79
|
+
|
|
80
|
+
In order to use the app, you need to have an active account with OneUptime at https://oneuptime.com. Please send an email to support@oneupitme.com if you need more details.
|
|
81
|
+
|
|
82
|
+
Create a new OneUptime Account: If you wish to sign up for a new account, you can do so at https://oneuptime.com and click on Sign up.
|
|
83
|
+
Help and Support: You can reach out to help and support here: https://oneuptime.com/support or contact support@oneuptime.com
|
|
84
|
+
`,
|
|
79
85
|
},
|
|
80
86
|
// Default to size-specific names; route will adjust if fallbacks are used
|
|
81
87
|
icons: {
|
|
@@ -142,8 +148,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
142
148
|
req,
|
|
143
149
|
res,
|
|
144
150
|
new BadDataException(
|
|
145
|
-
"Microsoft Teams App Client ID must be a valid GUID. Update the environment variable."
|
|
146
|
-
)
|
|
151
|
+
"Microsoft Teams App Client ID must be a valid GUID. Update the environment variable."
|
|
152
|
+
)
|
|
147
153
|
);
|
|
148
154
|
}
|
|
149
155
|
|
|
@@ -155,7 +161,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
155
161
|
res.setHeader("Content-Type", "application/zip");
|
|
156
162
|
res.setHeader(
|
|
157
163
|
"Content-Disposition",
|
|
158
|
-
'attachment; filename="oneuptime-teams-app.zip"'
|
|
164
|
+
'attachment; filename="oneuptime-teams-app.zip"'
|
|
159
165
|
);
|
|
160
166
|
|
|
161
167
|
// Create archive
|
|
@@ -174,11 +180,11 @@ export default class MicrosoftTeamsAPI {
|
|
|
174
180
|
|
|
175
181
|
const colorPath: string = path.join(
|
|
176
182
|
__dirname,
|
|
177
|
-
"../Images/MicrosoftTeams/color.png"
|
|
183
|
+
"../Images/MicrosoftTeams/color.png"
|
|
178
184
|
);
|
|
179
185
|
const outlinePath: string = path.join(
|
|
180
186
|
__dirname,
|
|
181
|
-
"../Images/MicrosoftTeams/outline.png"
|
|
187
|
+
"../Images/MicrosoftTeams/outline.png"
|
|
182
188
|
);
|
|
183
189
|
|
|
184
190
|
let colorIconBuffer: Buffer | null = null;
|
|
@@ -194,7 +200,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
194
200
|
iconOutlineName = "outline.png";
|
|
195
201
|
} else {
|
|
196
202
|
throw new BadDataException(
|
|
197
|
-
"Microsoft Teams icons not found. Expected either pre-sized icon-color-192x192.png and icon-outline-32x32.png in Common/Server/Images/MicrosoftTeams, or fallback color.png and outline.png."
|
|
203
|
+
"Microsoft Teams icons not found. Expected either pre-sized icon-color-192x192.png and icon-outline-32x32.png in Common/Server/Images/MicrosoftTeams, or fallback color.png and outline.png."
|
|
198
204
|
);
|
|
199
205
|
}
|
|
200
206
|
|
|
@@ -219,10 +225,10 @@ export default class MicrosoftTeamsAPI {
|
|
|
219
225
|
return Response.sendErrorResponse(
|
|
220
226
|
req,
|
|
221
227
|
res,
|
|
222
|
-
new BadDataException("Failed to create Teams app manifest zip")
|
|
228
|
+
new BadDataException("Failed to create Teams app manifest zip")
|
|
223
229
|
);
|
|
224
230
|
}
|
|
225
|
-
}
|
|
231
|
+
}
|
|
226
232
|
);
|
|
227
233
|
|
|
228
234
|
/*
|
|
@@ -237,7 +243,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
237
243
|
return Response.sendErrorResponse(
|
|
238
244
|
req,
|
|
239
245
|
res,
|
|
240
|
-
new BadDataException("Microsoft Teams App Client ID is not set")
|
|
246
|
+
new BadDataException("Microsoft Teams App Client ID is not set")
|
|
241
247
|
);
|
|
242
248
|
}
|
|
243
249
|
|
|
@@ -245,9 +251,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
245
251
|
return Response.sendErrorResponse(
|
|
246
252
|
req,
|
|
247
253
|
res,
|
|
248
|
-
new BadDataException(
|
|
249
|
-
"Microsoft Teams App Client Secret is not set",
|
|
250
|
-
),
|
|
254
|
+
new BadDataException("Microsoft Teams App Client Secret is not set")
|
|
251
255
|
);
|
|
252
256
|
}
|
|
253
257
|
|
|
@@ -258,9 +262,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
258
262
|
return Response.sendErrorResponse(
|
|
259
263
|
req,
|
|
260
264
|
res,
|
|
261
|
-
new BadRequestException(
|
|
262
|
-
"Invalid request - state param not present",
|
|
263
|
-
),
|
|
265
|
+
new BadRequestException("Invalid request - state param not present")
|
|
264
266
|
);
|
|
265
267
|
}
|
|
266
268
|
|
|
@@ -270,7 +272,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
270
272
|
return Response.sendErrorResponse(
|
|
271
273
|
req,
|
|
272
274
|
res,
|
|
273
|
-
new BadRequestException("Invalid state param")
|
|
275
|
+
new BadRequestException("Invalid state param")
|
|
274
276
|
);
|
|
275
277
|
}
|
|
276
278
|
|
|
@@ -279,14 +281,14 @@ export default class MicrosoftTeamsAPI {
|
|
|
279
281
|
|
|
280
282
|
const teamsIntegrationPageUrl: URL = URL.fromString(
|
|
281
283
|
DashboardClientUrl.toString() +
|
|
282
|
-
`/${projectId.toString()}/settings/microsoft-teams-integration
|
|
284
|
+
`/${projectId.toString()}/settings/microsoft-teams-integration`
|
|
283
285
|
);
|
|
284
286
|
|
|
285
287
|
if (error) {
|
|
286
288
|
return Response.redirect(
|
|
287
289
|
req,
|
|
288
290
|
res,
|
|
289
|
-
teamsIntegrationPageUrl.addQueryParam("error", error)
|
|
291
|
+
teamsIntegrationPageUrl.addQueryParam("error", error)
|
|
290
292
|
);
|
|
291
293
|
}
|
|
292
294
|
|
|
@@ -296,14 +298,14 @@ export default class MicrosoftTeamsAPI {
|
|
|
296
298
|
return Response.sendErrorResponse(
|
|
297
299
|
req,
|
|
298
300
|
res,
|
|
299
|
-
new BadRequestException("Invalid request - no authorization code")
|
|
301
|
+
new BadRequestException("Invalid request - no authorization code")
|
|
300
302
|
);
|
|
301
303
|
}
|
|
302
304
|
|
|
303
305
|
try {
|
|
304
306
|
// Exchange code for access token
|
|
305
307
|
const redirectUri: URL = URL.fromString(
|
|
306
|
-
`${AppApiClientUrl.toString()}/microsoft-teams/auth
|
|
308
|
+
`${AppApiClientUrl.toString()}/microsoft-teams/auth`
|
|
307
309
|
);
|
|
308
310
|
|
|
309
311
|
const tokenRequestBody: JSONObject = {
|
|
@@ -317,14 +319,14 @@ export default class MicrosoftTeamsAPI {
|
|
|
317
319
|
};
|
|
318
320
|
|
|
319
321
|
logger.debug(
|
|
320
|
-
"Microsoft Teams Token Request Body (static redirect): "
|
|
322
|
+
"Microsoft Teams Token Request Body (static redirect): "
|
|
321
323
|
);
|
|
322
324
|
logger.debug(tokenRequestBody);
|
|
323
325
|
|
|
324
326
|
const tokenResponse: HTTPErrorResponse | HTTPResponse<JSONObject> =
|
|
325
327
|
await API.post<JSONObject>({
|
|
326
328
|
url: URL.fromString(
|
|
327
|
-
"https://login.microsoftonline.com/common/oauth2/v2.0/token"
|
|
329
|
+
"https://login.microsoftonline.com/common/oauth2/v2.0/token"
|
|
328
330
|
),
|
|
329
331
|
data: tokenRequestBody,
|
|
330
332
|
headers: {
|
|
@@ -347,8 +349,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
347
349
|
req,
|
|
348
350
|
res,
|
|
349
351
|
new BadRequestException(
|
|
350
|
-
"Failed to get access token from Microsoft Teams"
|
|
351
|
-
)
|
|
352
|
+
"Failed to get access token from Microsoft Teams"
|
|
353
|
+
)
|
|
352
354
|
);
|
|
353
355
|
}
|
|
354
356
|
|
|
@@ -411,7 +413,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
411
413
|
return Response.redirect(
|
|
412
414
|
req,
|
|
413
415
|
res,
|
|
414
|
-
teamsIntegrationPageUrl.addQueryParam("needAdminConsent", "true")
|
|
416
|
+
teamsIntegrationPageUrl.addQueryParam("needAdminConsent", "true")
|
|
415
417
|
);
|
|
416
418
|
} catch (err) {
|
|
417
419
|
logger.error("Error in static Microsoft Teams auth callback: ");
|
|
@@ -419,10 +421,10 @@ export default class MicrosoftTeamsAPI {
|
|
|
419
421
|
return Response.sendErrorResponse(
|
|
420
422
|
req,
|
|
421
423
|
res,
|
|
422
|
-
new BadDataException("Failed to authenticate with Microsoft Teams")
|
|
424
|
+
new BadDataException("Failed to authenticate with Microsoft Teams")
|
|
423
425
|
);
|
|
424
426
|
}
|
|
425
|
-
}
|
|
427
|
+
}
|
|
426
428
|
);
|
|
427
429
|
|
|
428
430
|
// Endpoint to finalize team selection when multiple teams are available.
|
|
@@ -439,8 +441,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
439
441
|
req,
|
|
440
442
|
res,
|
|
441
443
|
new BadRequestException(
|
|
442
|
-
"projectId, userId and teamId are required"
|
|
443
|
-
)
|
|
444
|
+
"projectId, userId and teamId are required"
|
|
445
|
+
)
|
|
444
446
|
);
|
|
445
447
|
}
|
|
446
448
|
|
|
@@ -460,8 +462,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
460
462
|
req,
|
|
461
463
|
res,
|
|
462
464
|
new BadRequestException(
|
|
463
|
-
"User Microsoft Teams auth not found. Please re-authenticate."
|
|
464
|
-
)
|
|
465
|
+
"User Microsoft Teams auth not found. Please re-authenticate."
|
|
466
|
+
)
|
|
465
467
|
);
|
|
466
468
|
}
|
|
467
469
|
|
|
@@ -472,7 +474,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
472
474
|
projectId: projectId,
|
|
473
475
|
});
|
|
474
476
|
const matchedTeam: MicrosoftTeamsTeam | undefined = Object.values(
|
|
475
|
-
availableTeams
|
|
477
|
+
availableTeams
|
|
476
478
|
).find((t: MicrosoftTeamsTeam) => {
|
|
477
479
|
return t.id === teamId;
|
|
478
480
|
});
|
|
@@ -482,8 +484,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
482
484
|
req,
|
|
483
485
|
res,
|
|
484
486
|
new BadRequestException(
|
|
485
|
-
"Selected teamId is not in availableTeams list"
|
|
486
|
-
)
|
|
487
|
+
"Selected teamId is not in availableTeams list"
|
|
488
|
+
)
|
|
487
489
|
);
|
|
488
490
|
}
|
|
489
491
|
|
|
@@ -493,11 +495,11 @@ export default class MicrosoftTeamsAPI {
|
|
|
493
495
|
return Response.sendErrorResponse(
|
|
494
496
|
req,
|
|
495
497
|
res,
|
|
496
|
-
new BadRequestException("Invalid JWT token")
|
|
498
|
+
new BadRequestException("Invalid JWT token")
|
|
497
499
|
);
|
|
498
500
|
}
|
|
499
501
|
const payload: JSONObject = JSON.parse(
|
|
500
|
-
Buffer.from(tokenParts[1]!, "base64").toString("utf-8")
|
|
502
|
+
Buffer.from(tokenParts[1]!, "base64").toString("utf-8")
|
|
501
503
|
);
|
|
502
504
|
const tenantId: string = payload["tid"] as string;
|
|
503
505
|
|
|
@@ -505,7 +507,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
505
507
|
return Response.sendErrorResponse(
|
|
506
508
|
req,
|
|
507
509
|
res,
|
|
508
|
-
new BadRequestException("Tenant ID not found in token")
|
|
510
|
+
new BadRequestException("Tenant ID not found in token")
|
|
509
511
|
);
|
|
510
512
|
}
|
|
511
513
|
|
|
@@ -565,10 +567,10 @@ export default class MicrosoftTeamsAPI {
|
|
|
565
567
|
return Response.sendErrorResponse(
|
|
566
568
|
req,
|
|
567
569
|
res,
|
|
568
|
-
new BadDataException("Failed to select Microsoft Teams team")
|
|
570
|
+
new BadDataException("Failed to select Microsoft Teams team")
|
|
569
571
|
);
|
|
570
572
|
}
|
|
571
|
-
}
|
|
573
|
+
}
|
|
572
574
|
);
|
|
573
575
|
|
|
574
576
|
/*
|
|
@@ -583,7 +585,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
583
585
|
return Response.sendErrorResponse(
|
|
584
586
|
req,
|
|
585
587
|
res,
|
|
586
|
-
new BadDataException("Microsoft Teams App Client ID is not set")
|
|
588
|
+
new BadDataException("Microsoft Teams App Client ID is not set")
|
|
587
589
|
);
|
|
588
590
|
}
|
|
589
591
|
|
|
@@ -593,8 +595,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
593
595
|
req,
|
|
594
596
|
res,
|
|
595
597
|
new BadRequestException(
|
|
596
|
-
"Invalid request - state param not present"
|
|
597
|
-
)
|
|
598
|
+
"Invalid request - state param not present"
|
|
599
|
+
)
|
|
598
600
|
);
|
|
599
601
|
}
|
|
600
602
|
|
|
@@ -603,7 +605,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
603
605
|
return Response.sendErrorResponse(
|
|
604
606
|
req,
|
|
605
607
|
res,
|
|
606
|
-
new BadRequestException("Invalid state param")
|
|
608
|
+
new BadRequestException("Invalid state param")
|
|
607
609
|
);
|
|
608
610
|
}
|
|
609
611
|
|
|
@@ -627,17 +629,17 @@ export default class MicrosoftTeamsAPI {
|
|
|
627
629
|
}
|
|
628
630
|
|
|
629
631
|
const redirectUri: URL = URL.fromString(
|
|
630
|
-
`${AppApiClientUrl.toString()}/microsoft-teams/admin-consent/callback
|
|
632
|
+
`${AppApiClientUrl.toString()}/microsoft-teams/admin-consent/callback`
|
|
631
633
|
);
|
|
632
634
|
|
|
633
635
|
const adminConsentUrl: string = `https://login.microsoftonline.com/${encodeURIComponent(
|
|
634
|
-
tenantForConsent
|
|
636
|
+
tenantForConsent
|
|
635
637
|
)}/v2.0/adminconsent?client_id=${encodeURIComponent(
|
|
636
|
-
MicrosoftTeamsAppClientId
|
|
638
|
+
MicrosoftTeamsAppClientId
|
|
637
639
|
)}&scope=${encodeURIComponent(
|
|
638
|
-
"https://graph.microsoft.com/.default"
|
|
640
|
+
"https://graph.microsoft.com/.default"
|
|
639
641
|
)}&redirect_uri=${encodeURIComponent(redirectUri.toString())}&state=${encodeURIComponent(
|
|
640
|
-
stateParam
|
|
642
|
+
stateParam
|
|
641
643
|
)}`;
|
|
642
644
|
|
|
643
645
|
return Response.redirect(req, res, URL.fromString(adminConsentUrl));
|
|
@@ -648,11 +650,11 @@ export default class MicrosoftTeamsAPI {
|
|
|
648
650
|
req,
|
|
649
651
|
res,
|
|
650
652
|
new BadDataException(
|
|
651
|
-
"Failed to start Microsoft Teams admin consent"
|
|
652
|
-
)
|
|
653
|
+
"Failed to start Microsoft Teams admin consent"
|
|
654
|
+
)
|
|
653
655
|
);
|
|
654
656
|
}
|
|
655
|
-
}
|
|
657
|
+
}
|
|
656
658
|
);
|
|
657
659
|
|
|
658
660
|
/*
|
|
@@ -674,8 +676,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
674
676
|
req,
|
|
675
677
|
res,
|
|
676
678
|
new BadRequestException(
|
|
677
|
-
"Invalid request - state param not present"
|
|
678
|
-
)
|
|
679
|
+
"Invalid request - state param not present"
|
|
680
|
+
)
|
|
679
681
|
);
|
|
680
682
|
}
|
|
681
683
|
|
|
@@ -684,7 +686,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
684
686
|
return Response.sendErrorResponse(
|
|
685
687
|
req,
|
|
686
688
|
res,
|
|
687
|
-
new BadRequestException("Invalid state param")
|
|
689
|
+
new BadRequestException("Invalid state param")
|
|
688
690
|
);
|
|
689
691
|
}
|
|
690
692
|
|
|
@@ -692,7 +694,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
692
694
|
|
|
693
695
|
const teamsIntegrationPageUrl: URL = URL.fromString(
|
|
694
696
|
DashboardClientUrl.toString() +
|
|
695
|
-
`/${projectId.toString()}/settings/microsoft-teams-integration
|
|
697
|
+
`/${projectId.toString()}/settings/microsoft-teams-integration`
|
|
696
698
|
);
|
|
697
699
|
|
|
698
700
|
if (error) {
|
|
@@ -701,8 +703,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
701
703
|
res,
|
|
702
704
|
teamsIntegrationPageUrl.addQueryParam(
|
|
703
705
|
"error",
|
|
704
|
-
`${error}${errorDescription ? ": " + errorDescription : ""}
|
|
705
|
-
)
|
|
706
|
+
`${error}${errorDescription ? ": " + errorDescription : ""}`
|
|
707
|
+
)
|
|
706
708
|
);
|
|
707
709
|
}
|
|
708
710
|
|
|
@@ -712,8 +714,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
712
714
|
res,
|
|
713
715
|
teamsIntegrationPageUrl.addQueryParam(
|
|
714
716
|
"error",
|
|
715
|
-
"Missing tenant information from admin consent callback"
|
|
716
|
-
)
|
|
717
|
+
"Missing tenant information from admin consent callback"
|
|
718
|
+
)
|
|
717
719
|
);
|
|
718
720
|
}
|
|
719
721
|
|
|
@@ -723,8 +725,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
723
725
|
res,
|
|
724
726
|
teamsIntegrationPageUrl.addQueryParam(
|
|
725
727
|
"error",
|
|
726
|
-
"Microsoft Teams App credentials are not configured"
|
|
727
|
-
)
|
|
728
|
+
"Microsoft Teams App credentials are not configured"
|
|
729
|
+
)
|
|
728
730
|
);
|
|
729
731
|
}
|
|
730
732
|
|
|
@@ -739,7 +741,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
739
741
|
const tokenResp: HTTPErrorResponse | HTTPResponse<JSONObject> =
|
|
740
742
|
await API.post<JSONObject>({
|
|
741
743
|
url: URL.fromString(
|
|
742
|
-
`https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token
|
|
744
|
+
`https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`
|
|
743
745
|
),
|
|
744
746
|
data: {
|
|
745
747
|
client_id: MicrosoftTeamsAppClientId,
|
|
@@ -758,8 +760,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
758
760
|
res,
|
|
759
761
|
teamsIntegrationPageUrl.addQueryParam(
|
|
760
762
|
"error",
|
|
761
|
-
"Failed to get Graph app token after admin consent"
|
|
762
|
-
)
|
|
763
|
+
"Failed to get Graph app token after admin consent"
|
|
764
|
+
)
|
|
763
765
|
);
|
|
764
766
|
}
|
|
765
767
|
|
|
@@ -768,7 +770,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
768
770
|
(tokenData["access_token"] as string) || "";
|
|
769
771
|
const expiresInSec: number = Number(tokenData["expires_in"] || 0);
|
|
770
772
|
const expiresAtIso: string = new Date(
|
|
771
|
-
Date.now() + Math.max(0, (expiresInSec - 60) * 1000)
|
|
773
|
+
Date.now() + Math.max(0, (expiresInSec - 60) * 1000)
|
|
772
774
|
).toISOString();
|
|
773
775
|
|
|
774
776
|
logger.debug("App Access Token acquired via admin consent: ");
|
|
@@ -795,7 +797,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
795
797
|
| HTTPErrorResponse
|
|
796
798
|
| HTTPResponse<JSONObject> = await API.get<JSONObject>({
|
|
797
799
|
url: URL.fromString(
|
|
798
|
-
"https://graph.microsoft.com/v1.0/teams?$select=id,displayName"
|
|
800
|
+
"https://graph.microsoft.com/v1.0/teams?$select=id,displayName"
|
|
799
801
|
),
|
|
800
802
|
headers: {
|
|
801
803
|
Authorization: `Bearer ${appAccessToken}`,
|
|
@@ -810,8 +812,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
810
812
|
res,
|
|
811
813
|
teamsIntegrationPageUrl.addQueryParam(
|
|
812
814
|
"error",
|
|
813
|
-
"Failed to retrieve teams from Microsoft Graph API after admin consent"
|
|
814
|
-
)
|
|
815
|
+
"Failed to retrieve teams from Microsoft Graph API after admin consent"
|
|
816
|
+
)
|
|
815
817
|
);
|
|
816
818
|
}
|
|
817
819
|
|
|
@@ -825,8 +827,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
825
827
|
res,
|
|
826
828
|
teamsIntegrationPageUrl.addQueryParam(
|
|
827
829
|
"error",
|
|
828
|
-
"No teams available in your Microsoft 365 tenant. Please create a team first."
|
|
829
|
-
)
|
|
830
|
+
"No teams available in your Microsoft 365 tenant. Please create a team first."
|
|
831
|
+
)
|
|
830
832
|
);
|
|
831
833
|
}
|
|
832
834
|
|
|
@@ -839,7 +841,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
839
841
|
acc[team.name] = team;
|
|
840
842
|
return acc;
|
|
841
843
|
},
|
|
842
|
-
{} as Record<string, MicrosoftTeamsTeam
|
|
844
|
+
{} as Record<string, MicrosoftTeamsTeam>
|
|
843
845
|
);
|
|
844
846
|
} catch (error) {
|
|
845
847
|
logger.error("Error getting teams:");
|
|
@@ -849,8 +851,8 @@ export default class MicrosoftTeamsAPI {
|
|
|
849
851
|
res,
|
|
850
852
|
teamsIntegrationPageUrl.addQueryParam(
|
|
851
853
|
"error",
|
|
852
|
-
"Failed to retrieve teams from Microsoft Graph API"
|
|
853
|
-
)
|
|
854
|
+
"Failed to retrieve teams from Microsoft Graph API"
|
|
855
|
+
)
|
|
854
856
|
);
|
|
855
857
|
}
|
|
856
858
|
}
|
|
@@ -880,7 +882,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
880
882
|
res,
|
|
881
883
|
teamsIntegrationPageUrl
|
|
882
884
|
.addQueryParam("adminConsent", "success")
|
|
883
|
-
.addQueryParam("tenantId", tenantId)
|
|
885
|
+
.addQueryParam("tenantId", tenantId)
|
|
884
886
|
);
|
|
885
887
|
} catch (err) {
|
|
886
888
|
logger.error("Error in Microsoft Teams admin consent callback: ");
|
|
@@ -893,15 +895,15 @@ export default class MicrosoftTeamsAPI {
|
|
|
893
895
|
if (projectId) {
|
|
894
896
|
const teamsIntegrationPageUrl: URL = URL.fromString(
|
|
895
897
|
DashboardClientUrl.toString() +
|
|
896
|
-
`/${projectId.toString()}/settings/microsoft-teams-integration
|
|
898
|
+
`/${projectId.toString()}/settings/microsoft-teams-integration`
|
|
897
899
|
);
|
|
898
900
|
return Response.redirect(
|
|
899
901
|
req,
|
|
900
902
|
res,
|
|
901
903
|
teamsIntegrationPageUrl.addQueryParam(
|
|
902
904
|
"error",
|
|
903
|
-
"Failed to finalize Microsoft Teams admin consent"
|
|
904
|
-
)
|
|
905
|
+
"Failed to finalize Microsoft Teams admin consent"
|
|
906
|
+
)
|
|
905
907
|
);
|
|
906
908
|
}
|
|
907
909
|
} catch {
|
|
@@ -911,11 +913,11 @@ export default class MicrosoftTeamsAPI {
|
|
|
911
913
|
req,
|
|
912
914
|
res,
|
|
913
915
|
new BadDataException(
|
|
914
|
-
"Failed to finalize Microsoft Teams admin consent"
|
|
915
|
-
)
|
|
916
|
+
"Failed to finalize Microsoft Teams admin consent"
|
|
917
|
+
)
|
|
916
918
|
);
|
|
917
919
|
}
|
|
918
|
-
}
|
|
920
|
+
}
|
|
919
921
|
);
|
|
920
922
|
|
|
921
923
|
/*
|
|
@@ -936,7 +938,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
936
938
|
});
|
|
937
939
|
}
|
|
938
940
|
}
|
|
939
|
-
}
|
|
941
|
+
}
|
|
940
942
|
);
|
|
941
943
|
|
|
942
944
|
// Microsoft Teams webhook endpoint for interactive messages (legacy)
|
|
@@ -969,7 +971,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
969
971
|
req,
|
|
970
972
|
res,
|
|
971
973
|
authResult,
|
|
972
|
-
activity
|
|
974
|
+
activity
|
|
973
975
|
);
|
|
974
976
|
} else if (activityType === "invoke") {
|
|
975
977
|
// Handle adaptive card actions
|
|
@@ -977,7 +979,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
977
979
|
req,
|
|
978
980
|
res,
|
|
979
981
|
authResult,
|
|
980
|
-
activity
|
|
982
|
+
activity
|
|
981
983
|
);
|
|
982
984
|
}
|
|
983
985
|
|
|
@@ -987,7 +989,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
987
989
|
logger.error(error);
|
|
988
990
|
return Response.sendTextResponse(req, res, "");
|
|
989
991
|
}
|
|
990
|
-
}
|
|
992
|
+
}
|
|
991
993
|
);
|
|
992
994
|
|
|
993
995
|
// Test endpoint to verify Bot Framework setup
|
|
@@ -1011,7 +1013,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
1011
1013
|
clientId: MicrosoftTeamsAppClientId,
|
|
1012
1014
|
messagingEndpoint: `${AppApiClientUrl.toString()}/microsoft-bot/messages`,
|
|
1013
1015
|
});
|
|
1014
|
-
}
|
|
1016
|
+
}
|
|
1015
1017
|
);
|
|
1016
1018
|
|
|
1017
1019
|
// Connector configuration endpoint
|
|
@@ -1053,7 +1055,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
1053
1055
|
|
|
1054
1056
|
res.setHeader("Content-Type", "text/html");
|
|
1055
1057
|
return res.send(html);
|
|
1056
|
-
}
|
|
1058
|
+
}
|
|
1057
1059
|
);
|
|
1058
1060
|
|
|
1059
1061
|
// Get available teams for a project
|
|
@@ -1080,13 +1082,13 @@ export default class MicrosoftTeamsAPI {
|
|
|
1080
1082
|
id: team.id,
|
|
1081
1083
|
name: team.name,
|
|
1082
1084
|
};
|
|
1083
|
-
}
|
|
1085
|
+
}
|
|
1084
1086
|
),
|
|
1085
1087
|
});
|
|
1086
1088
|
} catch (err) {
|
|
1087
1089
|
return Response.sendErrorResponse(req, res, err as Exception);
|
|
1088
1090
|
}
|
|
1089
|
-
}
|
|
1091
|
+
}
|
|
1090
1092
|
);
|
|
1091
1093
|
|
|
1092
1094
|
// Endpoint to refresh teams list
|
|
@@ -1113,13 +1115,13 @@ export default class MicrosoftTeamsAPI {
|
|
|
1113
1115
|
id: team.id,
|
|
1114
1116
|
name: team.name,
|
|
1115
1117
|
};
|
|
1116
|
-
}
|
|
1118
|
+
}
|
|
1117
1119
|
),
|
|
1118
1120
|
});
|
|
1119
1121
|
} catch (err) {
|
|
1120
1122
|
return Response.sendErrorResponse(req, res, err as Exception);
|
|
1121
1123
|
}
|
|
1122
|
-
}
|
|
1124
|
+
}
|
|
1123
1125
|
);
|
|
1124
1126
|
|
|
1125
1127
|
return router;
|
|
@@ -1129,7 +1131,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
1129
1131
|
_req: ExpressRequest,
|
|
1130
1132
|
res: ExpressResponse,
|
|
1131
1133
|
authResult: MicrosoftTeamsRequest,
|
|
1132
|
-
activity: JSONObject
|
|
1134
|
+
activity: JSONObject
|
|
1133
1135
|
): Promise<void> {
|
|
1134
1136
|
// Handle direct messages to bot or @mentions
|
|
1135
1137
|
const messageText: string = (activity["text"] as string) || "";
|
|
@@ -1156,7 +1158,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
1156
1158
|
req: ExpressRequest,
|
|
1157
1159
|
res: ExpressResponse,
|
|
1158
1160
|
authResult: MicrosoftTeamsRequest,
|
|
1159
|
-
_activity: JSONObject
|
|
1161
|
+
_activity: JSONObject
|
|
1160
1162
|
): Promise<void> {
|
|
1161
1163
|
/*
|
|
1162
1164
|
* Handle adaptive card button clicks
|
|
@@ -1206,7 +1208,7 @@ export default class MicrosoftTeamsAPI {
|
|
|
1206
1208
|
action: action,
|
|
1207
1209
|
req: req,
|
|
1208
1210
|
res: res,
|
|
1209
|
-
}
|
|
1211
|
+
}
|
|
1210
1212
|
);
|
|
1211
1213
|
}
|
|
1212
1214
|
|
|
Binary file
|
|
@@ -1058,7 +1058,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
1058
1058
|
host,
|
|
1059
1059
|
new Route(AppApiRoute.toString())
|
|
1060
1060
|
.addRoute(new UserOnCallLogTimeline().crudApiPath!)
|
|
1061
|
-
.addRoute("/acknowledge/" + userOnCallLogTimelineId.toString()),
|
|
1061
|
+
.addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString()),
|
|
1062
1062
|
),
|
|
1063
1063
|
);
|
|
1064
1064
|
const url: URL = await ShortLinkService.getShortenedUrl(shortUrl);
|
|
@@ -1091,7 +1091,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
1091
1091
|
host,
|
|
1092
1092
|
new Route(AppApiRoute.toString())
|
|
1093
1093
|
.addRoute(new UserOnCallLogTimeline().crudApiPath!)
|
|
1094
|
-
.addRoute("/acknowledge/" + userOnCallLogTimelineId.toString()),
|
|
1094
|
+
.addRoute("/acknowledge-page/" + userOnCallLogTimelineId.toString()),
|
|
1095
1095
|
),
|
|
1096
1096
|
);
|
|
1097
1097
|
const url: URL = await ShortLinkService.getShortenedUrl(shortUrl);
|
|
@@ -1125,7 +1125,9 @@ export class Service extends DatabaseService<Model> {
|
|
|
1125
1125
|
host,
|
|
1126
1126
|
new Route(AppApiRoute.toString())
|
|
1127
1127
|
.addRoute(new UserOnCallLogTimeline().crudApiPath!)
|
|
1128
|
-
.addRoute(
|
|
1128
|
+
.addRoute(
|
|
1129
|
+
"/acknowledge-page/" + userOnCallLogTimelineId.toString(),
|
|
1130
|
+
),
|
|
1129
1131
|
),
|
|
1130
1132
|
);
|
|
1131
1133
|
|
|
@@ -1179,7 +1181,9 @@ export class Service extends DatabaseService<Model> {
|
|
|
1179
1181
|
host,
|
|
1180
1182
|
new Route(AppApiRoute.toString())
|
|
1181
1183
|
.addRoute(new UserOnCallLogTimeline().crudApiPath!)
|
|
1182
|
-
.addRoute(
|
|
1184
|
+
.addRoute(
|
|
1185
|
+
"/acknowledge-page/" + userOnCallLogTimelineId.toString(),
|
|
1186
|
+
),
|
|
1183
1187
|
),
|
|
1184
1188
|
);
|
|
1185
1189
|
|