@microsoft/teamsfx 0.7.1-beta.94bfabf9b.0 → 0.7.1-beta.98f67d6b7.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.
@@ -1902,6 +1902,41 @@ class TeamsFx {
1902
1902
  }
1903
1903
  }
1904
1904
 
1905
+ // Copyright (c) Microsoft Corporation.
1906
+ // Licensed under the MIT license.
1907
+ /**
1908
+ * @internal
1909
+ */
1910
+ function cloneConversation(conversation) {
1911
+ return JSON.parse(JSON.stringify(conversation));
1912
+ }
1913
+ /**
1914
+ * @internal
1915
+ */
1916
+ function getTargetType(conversationReference) {
1917
+ var _a;
1918
+ const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
1919
+ if (conversationType === "personal") {
1920
+ return "Person";
1921
+ }
1922
+ else if (conversationType === "groupChat") {
1923
+ return "Group";
1924
+ }
1925
+ else if (conversationType === "channel") {
1926
+ return "Channel";
1927
+ }
1928
+ else {
1929
+ return undefined;
1930
+ }
1931
+ }
1932
+ /**
1933
+ * @internal
1934
+ */
1935
+ function getTeamsBotInstallationId(context) {
1936
+ var _a, _b, _c, _d;
1937
+ return (_d = (_c = (_b = (_a = context.activity) === null || _a === void 0 ? void 0 : _a.channelData) === null || _b === void 0 ? void 0 : _b.team) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : context.activity.conversation.id;
1938
+ }
1939
+
1905
1940
  // Copyright (c) Microsoft Corporation.
1906
1941
  /**
1907
1942
  * @internal
@@ -1932,8 +1967,7 @@ class NotificationMiddleware {
1932
1967
  break;
1933
1968
  }
1934
1969
  case ActivityType.CurrentBotMessaged: {
1935
- const reference = TurnContext.getConversationReference(context.activity);
1936
- await this.tryAddMessagedReference(reference);
1970
+ await this.tryAddMessagedReference(context);
1937
1971
  break;
1938
1972
  }
1939
1973
  case ActivityType.CurrentBotUninstalled:
@@ -1971,14 +2005,25 @@ class NotificationMiddleware {
1971
2005
  }
1972
2006
  return ActivityType.Unknown;
1973
2007
  }
1974
- async tryAddMessagedReference(reference) {
1975
- var _a;
2008
+ async tryAddMessagedReference(context) {
2009
+ var _a, _b, _c, _d;
2010
+ const reference = TurnContext.getConversationReference(context.activity);
1976
2011
  const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
1977
2012
  if (conversationType === "personal" || conversationType === "groupChat") {
1978
2013
  if (!(await this.conversationReferenceStore.check(reference))) {
1979
2014
  await this.conversationReferenceStore.set(reference);
1980
2015
  }
1981
2016
  }
2017
+ else if (conversationType === "channel") {
2018
+ const teamId = (_d = (_c = (_b = context.activity) === null || _b === void 0 ? void 0 : _b.channelData) === null || _c === void 0 ? void 0 : _c.team) === null || _d === void 0 ? void 0 : _d.id;
2019
+ if (teamId !== undefined) {
2020
+ const teamReference = cloneConversation(reference);
2021
+ teamReference.conversation.id = teamId;
2022
+ if (!(await this.conversationReferenceStore.check(teamReference))) {
2023
+ await this.conversationReferenceStore.set(teamReference);
2024
+ }
2025
+ }
2026
+ }
1982
2027
  }
1983
2028
  }
1984
2029
  class CommandResponseMiddleware {
@@ -2218,41 +2263,6 @@ class ConversationReferenceStore {
2218
2263
  }
2219
2264
  }
2220
2265
 
2221
- // Copyright (c) Microsoft Corporation.
2222
- // Licensed under the MIT license.
2223
- /**
2224
- * @internal
2225
- */
2226
- function cloneConversation(conversation) {
2227
- return Object.assign({}, conversation);
2228
- }
2229
- /**
2230
- * @internal
2231
- */
2232
- function getTargetType(conversationReference) {
2233
- var _a;
2234
- const conversationType = (_a = conversationReference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
2235
- if (conversationType === "personal") {
2236
- return "Person";
2237
- }
2238
- else if (conversationType === "groupChat") {
2239
- return "Group";
2240
- }
2241
- else if (conversationType === "channel") {
2242
- return "Channel";
2243
- }
2244
- else {
2245
- return undefined;
2246
- }
2247
- }
2248
- /**
2249
- * @internal
2250
- */
2251
- function getTeamsBotInstallationId(context) {
2252
- var _a, _b, _c, _d;
2253
- return (_d = (_c = (_b = (_a = context.activity) === null || _a === void 0 ? void 0 : _a.channelData) === null || _b === void 0 ? void 0 : _b.team) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : context.activity.conversation.id;
2254
- }
2255
-
2256
2266
  // Copyright (c) Microsoft Corporation.
2257
2267
  /**
2258
2268
  * Send a plain text message to a notification target.
@@ -2572,12 +2582,12 @@ class NotificationBot {
2572
2582
  if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
2573
2583
  throw new Error("NotificationBot has not been initialized.");
2574
2584
  }
2575
- const references = (await this.conversationReferenceStore.getAll()).values();
2585
+ const references = await this.conversationReferenceStore.getAll();
2576
2586
  const targets = [];
2577
2587
  for (const reference of references) {
2578
2588
  // validate connection
2579
2589
  let valid = true;
2580
- this.adapter.continueConversation(reference, async (context) => {
2590
+ await this.adapter.continueConversation(reference, async (context) => {
2581
2591
  try {
2582
2592
  // try get member to see if the installation is still valid
2583
2593
  await TeamsInfo.getPagedMembers(context, 1);
@@ -2592,7 +2602,7 @@ class NotificationBot {
2592
2602
  targets.push(new TeamsBotInstallation(this.adapter, reference));
2593
2603
  }
2594
2604
  else {
2595
- this.conversationReferenceStore.delete(reference);
2605
+ await this.conversationReferenceStore.delete(reference);
2596
2606
  }
2597
2607
  }
2598
2608
  return targets;