8000 return invoke response from process_activity · TheCompuGuru/botbuilder-python@1efa62b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1efa62b

Browse files
author
Eric Dahlvang
committed
return invoke response from process_activity
1 parent 2056007 commit 1efa62b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

libraries/botbuilder-core/botbuilder/core/bot_framework_adapter.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .bot_adapter import BotAdapter
3939
from .turn_context import TurnContext
4040
from .user_token_provider import UserTokenProvider
41+
from .invoke_response import InvokeResponse
4142
from .conversation_reference_extension import get_continuation_activity
4243

4344
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):
263264
teams_channel_data["tenant"]["id"]
264265
)
265266

266-
pipeline_result = await self.run_pipeline(context, logic)
267+
await self.run_pipeline(context, logic)
267268

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
271278

272279
async def authenticate_request(
273280
self, request: Activity, auth_header: str
@@ -287,7 +294,7 @@ async def authenticate_request(
287294
)
288295

289296
if not claims.is_authenticated:
290-
raise Exception("Unauthorized Access. Request is not authorized")
297+
raise PermissionError("Unauthorized Access. Request is not authorized")
291298

292299
return claims
293300

0 commit comments

Comments
 (0)
0