payload: {"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/5292","repository_url":"https://api.github.com/repos/Microsoft/BotBuilder","labels_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/5292/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/5292/comments","events_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/5292/events","html_url":"https://github.com/Microsoft/BotBuilder/issues/5292","id":409031590,"node_id":"MDU6SXNzdWU0MDkwMzE1OTA=","number":5292,"title":"DCR: patch incoming ConversationUpdate activities","user":{"login":"Stevenic","id":698939,"node_id":"MDQ6VXNlcjY5ODkzOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/698939?v=4","gravatar_id":"","url":"https://api.github.com/users/Stevenic","html_url":"https://github.com/Stevenic","followers_url":"https://api.github.com/users/Stevenic/followers","following_url":"https://api.github.com/users/Stevenic/following{/other_user}","gists_url":"https://api.github.com/users/Stevenic/gists{/gist_id}","starred_url":"https://api.github.com/users/Stevenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stevenic/subscriptions","organizations_url":"https://api.github.com/users/Stevenic/orgs","repos_url":"https://api.github.com/users/Stevenic/repos","events_url":"https://api.github.com/users/Stevenic/events{/privacy}","received_events_url":"https://api.github.com/users/Stevenic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-02-11T23:40:59Z","updated_at":"2019-02-11T23:40:59Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## Issue\r\nThe `ConversationUpdate` activity sometimes has the wrong or missing \"from\" field. This can result in the following issues: \r\n\r\n- Changes made to UserState are lost because the changes are saved to a bogus users storage record.\r\n- Direct conversations with the user added can't be started because of the bogus account info.\r\n\r\n## Proposed change\r\nI currently have a piece of middleware that patches the missing from field but its been proposed that we move this logic into the `BotFrameworkAdapter` so that developers don't need to know they should add this middleware.  The code I use to do the patch is listed below:\r\n\r\n```TS\r\nexport class PatchFromMiddleware implements Middleware {\r\n\r\n    public async onTurn(context: TurnContext, next: () => Promise<void>): Promise<void> {\r\n        if (context.activity && context.activity.type === ActivityTypes.ConversationUpdate) {\r\n            // Get list of members added or removed\r\n            const members = context.activity.membersAdded ? context.activity.membersAdded : context.activity.membersRemoved;\r\n\r\n            // Filter out \"bot\" for list of accounts\r\n            const accounts = members && context.activity.recipient ? members.filter((m) => m.id !== (context.activity as any).recipient) : [];\r\n\r\n            // Patch from field\r\n            const cnt = accounts.length;\r\n            if (cnt > 0 && (cnt === 1 || !context.activity.from)) {\r\n                context.activity.from = accounts[0];\r\n            }\r\n        }\r\n        await next();\r\n    }\r\n}\r\n```\r\n\r\n## Component Impact \r\nThe `BotFrameworkAdapter`.\r\n\r\n## Tracking Status\r\n**Dotnet SDK**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n**Javascript SDK**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n**Java SDK**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n**Python SDK**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n**Emulator**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n**Samples**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n\r\n**Docs**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n\r\n**Tools**\r\n- [ ] PR\r\n- [ ] Merged\r\n\r\n[dcr]\r\n"}}
other: {"actor":{"display_login":"Stevenic"}}