botbuilder-python
botbuilder-python copied to clipboard
Fix Middleware Chain to Allow Awaiting Final Logic Result
Fixes #2197
Description
Previously, the middleware chain executed each handler sequentially, but none could await the final logic result. This prevented middlewares from processing the response of the last middleware (which runs the actual logic).
This PR updates the TurnContext class in the botbuilder-core library to modify the middleware chain handling. The changes ensure that middleware can await the result of the "next" middleware, including the final logic.
This allows for more flexible and powerful middleware handling.
Specific Changes
1. TurnContext Class:
- Modified the
_emitmethod to ensure that each middleware can await the result of the next middleware in the chain, including the final logic. - Updated the
_emitmethod to return the result of the logic coroutine correctly.
2. Test Cases:
- Updated the
test_update_activity_should_apply_conversation_referencetest case to handle theResourceResponsecorrectly and ensure theupdate_activitymethod returns the correctResourceResponse.