38
38
from .bot_adapter import BotAdapter
39
39
from .turn_context import TurnContext
40
40
from .user_token_provider import UserTokenProvider
41
+ from .invoke_response import InvokeResponse
41
42
from .conversation_reference_extension import get_continuation_activity
42
43
43
44
USER_AGENT = f"Microsoft-BotFramework/3.1 (BotBuilder Python/{ __version__ } )"
@@ -263,11 +264,17 @@ async def process_activity(self, req, auth_header: str, logic: Callable):
263
264
teams_channel_data ["tenant" ]["id" ]
264
265
)
265
266
266
- pipeline_result = await self .run_pipeline (context , logic )
267
+ await self .run_pipeline (context , logic )
267
268
268
- return pipeline_result or context .turn_state .get (
269
- BotFrameworkAdapter ._INVOKE_RESPONSE_KEY # pylint: disable=protected-access
270
- )
269
+ if activity .type == ActivityTypes .invoke :
270
+ invoke_response = context .turn_state .get (
271
+ BotFrameworkAdapter ._INVOKE_RESPONSE_KEY # pylint: disable=protected-access
272
+ )
273
+ if invoke_response is None :
274
+ return InvokeResponse (status = 501 )
275
+ return invoke_response .value
276
+
277
+ return None
271
278
272
279
async def authenticate_request (
273
280
self , request : Activity , auth_header : str
@@ -287,7 +294,7 @@ async def authenticate_request(
287
294
)
288
295
289
296
if not claims .is_authenticated :
290
- raise Exception ("Unauthorized Access. Request is not authorized" )
297
+ raise PermissionError ("Unauthorized Access. Request is not authorized" )
291
298
292
299
return claims
293
300
0 commit comments