@microsoft/teamsfx 2.2.3-alpha.0c7c513de.0 → 2.2.3-alpha.25b558a2a.0

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.
@@ -815,7 +815,7 @@ class MsGraphAuthProvider {
815
815
  * };
816
816
  * const prompt = new TeamsBotSsoPrompt(dialogId, {
817
817
  * config: config
818
- * scopes: '["User.Read"],
818
+ * scopes: ["User.Read"],
819
819
  * });
820
820
  * this.addDialog(prompt);
821
821
  *
@@ -4556,6 +4556,27 @@ class NotificationBot {
4556
4556
  }
4557
4557
  return new TeamsBotInstallation(this.adapter, conversationReference, this.botAppId);
4558
4558
  }
4559
+ /**
4560
+ * Validate the installation by getting paged memebers.
4561
+ *
4562
+ * @param conversationReference The bound `ConversationReference`.
4563
+ * @returns Returns false if recieves `BotNotInConversationRoster` error, otherwise returns true.
4564
+ */
4565
+ async validateInstallation(conversationReference) {
4566
+ let isValid = true;
4567
+ await this.adapter.continueConversationAsync(this.botAppId, conversationReference, async (context) => {
4568
+ try {
4569
+ // try get member to see if the installation is still valid
4570
+ await TeamsInfo.getPagedMembers(context, 1);
4571
+ }
4572
+ catch (error) {
4573
+ if (error.code === "BotNotInConversationRoster") {
4574
+ isValid = false;
4575
+ }
4576
+ }
4577
+ });
4578
+ return isValid;
4579
+ }
4559
4580
  /**
4560
4581
  * Gets a pagined list of targets where the bot is installed.
4561
4582
  *
@@ -4567,7 +4588,7 @@ class NotificationBot {
4567
4588
  *
4568
4589
  * @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
4569
4590
  */
4570
- async getPagedInstallations(pageSize, continuationToken) {
4591
+ async getPagedInstallations(pageSize, continuationToken, validationEnabled = true) {
4571
4592
  if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
4572
4593
  throw new Error("NotificationBot has not been initialized.");
4573
4594
  }
@@ -4575,19 +4596,12 @@ class NotificationBot {
4575
4596
  const targets = [];
4576
4597
  for (const reference of references.data) {
4577
4598
  // validate connection
4578
- let valid = true;
4579
- await this.adapter.continueConversationAsync(this.botAppId, reference, async (context) => {
4580
- try {
4581
- // try get member to see if the installation is still valid
4582
- await TeamsInfo.getPagedMembers(context, 1);
4583
- }
4584
- catch (error) {
4585
- if (error.code === "BotNotInConversationRoster") {
4586
- valid = false;
4587
- }
4588
- }
4589
- });
4590
- if (valid) {
4599
+ let valid;
4600
+ if (validationEnabled) {
4601
+ // try get member to see if the installation is still valid
4602
+ valid = await this.validateInstallation(reference);
4603
+ }
4604
+ if (!validationEnabled || (validationEnabled && valid)) {
4591
4605
  targets.push(new TeamsBotInstallation(this.adapter, reference, this.botAppId));
4592
4606
  }
4593
4607
  else {