Skip to content

Commit 29ffbb8

Browse files
committed
refactor: delegate channel/thread_ts validation to the API in agent chat_stream()
1 parent f32af71 commit 29ffbb8

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

slack_bolt/agent/agent.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,9 @@ def chat_stream(
6363
raise ValueError(
6464
"Either provide all of channel, thread_ts, recipient_team_id, and recipient_user_id, or none of them"
6565
)
66-
resolved_channel = channel or self._channel_id
67-
resolved_thread_ts = thread_ts or self._thread_ts
68-
if resolved_channel is None:
69-
raise ValueError(
70-
"channel is required: provide it as an argument or ensure channel_id is set in the event context"
71-
)
72-
if resolved_thread_ts is None:
73-
raise ValueError(
74-
"thread_ts is required: provide it as an argument or ensure thread_ts is set in the event context"
75-
)
7666
return self._client.chat_stream(
77-
channel=resolved_channel,
78-
thread_ts=resolved_thread_ts,
67+
channel=channel or self._channel_id,
68+
thread_ts=thread_ts or self._thread_ts,
7969
recipient_team_id=recipient_team_id or self._team_id,
8070
recipient_user_id=recipient_user_id or self._user_id,
8171
**kwargs,

slack_bolt/agent/async_agent.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,9 @@ async def chat_stream(
6060
raise ValueError(
6161
"Either provide all of channel, thread_ts, recipient_team_id, and recipient_user_id, or none of them"
6262
)
63-
resolved_channel = channel or self._channel_id
64-
resolved_thread_ts = thread_ts or self._thread_ts
65-
if resolved_channel is None:
66-
raise ValueError(
67-
"channel is required: provide it as an argument or ensure channel_id is set in the event context"
68-
)
69-
if resolved_thread_ts is None:
70-
raise ValueError(
71-
"thread_ts is required: provide it as an argument or ensure thread_ts is set in the event context"
72-
)
7363
return await self._client.chat_stream(
74-
channel=resolved_channel,
75-
thread_ts=resolved_thread_ts,
64+
channel=channel or self._channel_id,
65+
thread_ts=thread_ts or self._thread_ts,
7666
recipient_team_id=recipient_team_id or self._team_id,
7767
recipient_user_id=recipient_user_id or self._user_id,
7868
**kwargs,

0 commit comments

Comments
 (0)