From 4f24917e56c9c816a9eec33eaadb74d7a5552197 Mon Sep 17 00:00:00 2001 From: Corina Date: Thu, 6 Dec 2018 15:18:45 -0800 Subject: [PATCH 1/2] Bump Web Chat to fix transcript imports --- package-lock.json | 61 ++++++++++++------- packages/app/client/package.json | 2 +- .../client/src/ui/shell/mdi/tabBar/tabBar.tsx | 2 +- packages/app/main/src/utils/conversation.ts | 33 +++++++--- .../core/src/facility/conversation.ts | 36 +++++++---- 5 files changed, 89 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index b6fa58ddf..0e4a7a0e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4271,9 +4271,9 @@ } }, "botframework-directlinejs": { - "version": "0.9.17", - "resolved": "https://registry.npmjs.org/botframework-directlinejs/-/botframework-directlinejs-0.9.17.tgz", - "integrity": "sha512-Ib2BhalcxbKi5rtCO1OX5VhWkfb/rN/voq5823hCIvd/p+GCI/G9jEnxzRcfFWmLUk6hWYjwUnKarIeg93YiMA==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/botframework-directlinejs/-/botframework-directlinejs-0.10.0.tgz", + "integrity": "sha512-J8a2Hp2qEmehIgAsxvW6v8YsVyqzbdfAvX7ugxWw/vEB579xwFCDQ8A1GYwlFiFsUfBeeFet5XROSI55ELfUKA==", "requires": { "rxjs": "^5.0.3" } @@ -4294,13 +4294,13 @@ } }, "botframework-webchat": { - "version": "0.14.3-master.b0553fd", - "resolved": "https://registry.npmjs.org/botframework-webchat/-/botframework-webchat-0.14.3-master.b0553fd.tgz", - "integrity": "sha512-K1RJ39vGTzWjvZ5v/ggtCe9Ce5yA/8eb6cqtzkQXiviiKcjYGAyA0T6qfPSV/fRKBB2E++WLsHWNcUftASFEFg==", + "version": "0.15.1-v3.4da20d6", + "resolved": "https://registry.npmjs.org/botframework-webchat/-/botframework-webchat-0.15.1-v3.4da20d6.tgz", + "integrity": "sha512-ILZJgnX+TQKflDSObsv79Opnbkoi++nvuDvD1E/9L3T7w52LQf3RBv5DTDRVYqiQzhPFeqlXSTkoPR9RZt+w3g==", "requires": { "adaptivecards": "1.0.0", "bluebird": "^3.5.1", - "botframework-directlinejs": "0.9.17", + "botframework-directlinejs": "^0.10.0", "core-js": "2.4.1", "jspeech": "^0.1.1", "markdown-it": "8.3.1", @@ -8466,7 +8466,8 @@ "ansi-regex": { "version": "2.1.1", "resolved": false, - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "optional": true }, "aproba": { "version": "1.2.0", @@ -8487,12 +8488,14 @@ "balanced-match": { "version": "1.0.0", "resolved": false, - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": false, "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8507,17 +8510,20 @@ "code-point-at": { "version": "1.1.0", "resolved": false, - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": false, - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -8634,7 +8640,8 @@ "inherits": { "version": "2.0.3", "resolved": false, - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "optional": true }, "ini": { "version": "1.3.5", @@ -8646,6 +8653,7 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -8660,6 +8668,7 @@ "version": "3.0.4", "resolved": false, "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -8667,12 +8676,14 @@ "minimist": { "version": "0.0.8", "resolved": false, - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "optional": true }, "minipass": { "version": "2.2.4", "resolved": false, "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -8691,6 +8702,7 @@ "version": "0.5.1", "resolved": false, "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "optional": true, "requires": { "minimist": "0.0.8" } @@ -8771,7 +8783,8 @@ "number-is-nan": { "version": "1.0.1", "resolved": false, - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "optional": true }, "object-assign": { "version": "4.1.1", @@ -8783,6 +8796,7 @@ "version": "1.4.0", "resolved": false, "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "optional": true, "requires": { "wrappy": "1" } @@ -8868,7 +8882,8 @@ "safe-buffer": { "version": "5.1.1", "resolved": false, - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -8904,6 +8919,7 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -8923,6 +8939,7 @@ "version": "3.0.1", "resolved": false, "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -8966,12 +8983,14 @@ "wrappy": { "version": "1.0.2", "resolved": false, - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "optional": true }, "yallist": { "version": "3.0.2", "resolved": false, - "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=" + "integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", + "optional": true } } }, @@ -12269,9 +12288,9 @@ } }, "linkify-it": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz", - "integrity": "sha1-2UpGSPmxwXnWT6lykSaL22zpQ08=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.1.0.tgz", + "integrity": "sha512-4REs8/062kV2DSHxNfq5183zrqXMl7WP0WzABH9IeJI+NLm429FgE1PDecltYfnOoFDFlZGh2T8PfZn0r+GTRg==", "requires": { "uc.micro": "^1.0.1" } diff --git a/packages/app/client/package.json b/packages/app/client/package.json index 0239b0d61..55c07fbd0 100644 --- a/packages/app/client/package.json +++ b/packages/app/client/package.json @@ -96,7 +96,7 @@ "@uifabric/styling": "^5.20.0", "base64url": "2.0.0", "botframework-config": "4.0.0-preview1.3.4", - "botframework-webchat": "0.14.3-master.b0553fd", + "botframework-webchat": "^0.15.1-v3.4da20d6", "react": "~16.3.2", "react-dom": "~16.3.2", "react-redux": "^5.0.7", diff --git a/packages/app/client/src/ui/shell/mdi/tabBar/tabBar.tsx b/packages/app/client/src/ui/shell/mdi/tabBar/tabBar.tsx index 0bbcd5257..c184294f0 100644 --- a/packages/app/client/src/ui/shell/mdi/tabBar/tabBar.tsx +++ b/packages/app/client/src/ui/shell/mdi/tabBar/tabBar.tsx @@ -162,7 +162,7 @@ export class TabBar extends React.Component { private get tabs(): JSX.Element[] { return this.props.tabOrder.map((documentId, index) => { - const document = this.props.documents[documentId]; + const document = this.props.documents[documentId] || {}; const isActive = documentId === this.props.activeDocumentId; return ( diff --git a/packages/app/main/src/utils/conversation.ts b/packages/app/main/src/utils/conversation.ts index c8741c5b9..f51227117 100644 --- a/packages/app/main/src/utils/conversation.ts +++ b/packages/app/main/src/utils/conversation.ts @@ -20,17 +20,30 @@ export function cleanupId( ) { const roleIdMap = { bot: botId, user: userId }; - activities = activities.map(activity => ({ - ...activity, - from: { - ...activity.from, - id: roleIdMap[activity.from.role] || activity.from.id - }, - recipient: { - ...activity.recipient, - id: roleIdMap[activity.recipient.role] || activity.recipient.id + activities = activities.map((activity: any) => { + const { type } = activity; + + if ( + type === 'event' + || type === 'message' + || type === 'messageReaction' + || type === 'typing' + ) { + activity = { + ...activity, + from: { + ...activity.from, + id: roleIdMap[activity.from.role] || activity.from.id + }, + recipient: { + ...activity.recipient, + id: roleIdMap[activity.recipient.role] || activity.recipient.id + } + }; } - })); + + return activity; + }); return activities; } diff --git a/packages/emulator/core/src/facility/conversation.ts b/packages/emulator/core/src/facility/conversation.ts index 07923086b..a952b3ba5 100644 --- a/packages/emulator/core/src/facility/conversation.ts +++ b/packages/emulator/core/src/facility/conversation.ts @@ -555,20 +555,32 @@ export default class Conversation extends EventEmitter { const { id: currUserId } = this.user; let origUserId = null; let origBotId = null; + // Get original botId and userId // Fixup conversationId - activities.forEach(activity => { - if (!origBotId && activity.recipient.role === 'bot') { - origBotId = activity.recipient.id; - } - - if (!origUserId && activity.recipient.role === 'user') { - origUserId = activity.recipient.id; - } - + activities.forEach( (activity) => { if (activity.conversation) { activity.conversation.id = this.conversationId; } + + const { type } = activity; + + if ( + activity.recipient && ( + type === 'event' + || type === 'message' + || type === 'messageReaction' + || type === 'typing' + ) + ) { + if (!origBotId && activity.recipient.role === 'bot') { + origBotId = activity.recipient.id; + } + + if (!origUserId && activity.recipient.role === 'user') { + origUserId = activity.recipient.id; + } + } }); // Fixup recipient and from ids @@ -594,10 +606,10 @@ export default class Conversation extends EventEmitter { // Add activities to the queue activities.forEach(activity => { - if (activity.recipient.role === 'user') { + if (activity.recipient && activity.recipient.role === 'user') { activity = this.processActivity(activity); } - + this.addActivityToQueue(activity); }); } @@ -678,7 +690,7 @@ export default class Conversation extends EventEmitter { const genericActivity = activity as GenericActivity; - if (genericActivity) { + if (genericActivity && activity.recipient) { this.botEmulator.facilities.logger.logActivity(this.conversationId, genericActivity, activity.recipient.role); } } From 0654a71d7e0832487343c271d41d76c05423c62c Mon Sep 17 00:00:00 2001 From: Corina Date: Thu, 6 Dec 2018 15:33:07 -0800 Subject: [PATCH 2/2] PR Fix --- packages/app/client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/client/package.json b/packages/app/client/package.json index 55c07fbd0..96fd189f9 100644 --- a/packages/app/client/package.json +++ b/packages/app/client/package.json @@ -96,7 +96,7 @@ "@uifabric/styling": "^5.20.0", "base64url": "2.0.0", "botframework-config": "4.0.0-preview1.3.4", - "botframework-webchat": "^0.15.1-v3.4da20d6", + "botframework-webchat": "0.15.1-v3.4da20d6", "react": "~16.3.2", "react-dom": "~16.3.2", "react-redux": "^5.0.7",