Skip to content

Commit 8e60528

Browse files
authored
feat(web-api): add session_status to chat.stopStream and chat_stream stop() helpers (#1945)
1 parent 21f62ba commit 8e60528

7 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎slack_sdk/web/async_chat_stream.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ async def stop(
158158
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
159159
blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
160160
metadata: Optional[Union[Dict, Metadata]] = None,
161+
session_status: Optional[str] = None,
161162
**kwargs,
162163
) -> AsyncSlackResponse:
163164
"""Stop the stream and finalize the message.
@@ -169,6 +170,7 @@ async def stop(
169170
what will be appended to the message received so far.
170171
metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
171172
post to Slack is accessible to any app or user who is a member of that workspace.
173+
session_status: The session status to set after stopping the stream.
172174
**kwargs: Additional arguments passed to the underlying API calls.
173175
174176
Returns:
@@ -217,6 +219,7 @@ async def stop(
217219
blocks=blocks,
218220
chunks=flushings,
219221
metadata=metadata,
222+
session_status=session_status,
220223
**kwargs,
221224
)
222225
self._state = "completed"

‎slack_sdk/web/async_client.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,7 @@ async def chat_stopStream(
30293029
blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
30303030
metadata: Optional[Union[Dict, Metadata]] = None,
30313031
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
3032+
session_status: Optional[str] = None,
30323033
**kwargs,
30333034
) -> AsyncSlackResponse:
30343035
"""Stops a streaming conversation.
@@ -3042,6 +3043,7 @@ async def chat_stopStream(
30423043
"blocks": blocks,
30433044
"metadata": metadata,
30443045
"chunks": chunks,
3046+
"session_status": session_status,
30453047
}
30463048
)
30473049
_parse_web_class_objects(kwargs)

‎slack_sdk/web/chat_stream.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def stop(
148148
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
149149
blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
150150
metadata: Optional[Union[Dict, Metadata]] = None,
151+
session_status: Optional[str] = None,
151152
**kwargs,
152153
) -> SlackResponse:
153154
"""Stop the stream and finalize the message.
@@ -159,6 +160,7 @@ def stop(
159160
what will be appended to the message received so far.
160161
metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
161162
post to Slack is accessible to any app or user who is a member of that workspace.
163+
session_status: The session status to set after stopping the stream.
162164
**kwargs: Additional arguments passed to the underlying API calls.
163165
164166
Returns:
@@ -207,6 +209,7 @@ def stop(
207209
blocks=blocks,
208210
chunks=flushings,
209211
metadata=metadata,
212+
session_status=session_status,
210213
**kwargs,
211214
)
212215
self._state = "completed"

‎slack_sdk/web/client.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3019,6 +3019,7 @@ def chat_stopStream(
30193019
blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
30203020
metadata: Optional[Union[Dict, Metadata]] = None,
30213021
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
3022+
session_status: Optional[str] = None,
30223023
**kwargs,
30233024
) -> SlackResponse:
30243025
"""Stops a streaming conversation.
@@ -3032,6 +3033,7 @@ def chat_stopStream(
30323033
"blocks": blocks,
30333034
"metadata": metadata,
30343035
"chunks": chunks,
3036+
"session_status": session_status,
30353037
}
30363038
)
30373039
_parse_web_class_objects(kwargs)

‎slack_sdk/web/legacy_client.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,7 @@ def chat_stopStream(
30293029
blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
30303030
metadata: Optional[Union[Dict, Metadata]] = None,
30313031
chunks: Optional[Sequence[Union[Dict, Chunk]]] = None,
3032+
session_status: Optional[str] = None,
30323033
**kwargs,
30333034
) -> Union[Future, SlackResponse]:
30343035
"""Stops a streaming conversation.
@@ -3042,6 +3043,7 @@ def chat_stopStream(
30423043
"blocks": blocks,
30433044
"metadata": metadata,
30443045
"chunks": chunks,
3046+
"session_status": session_status,
30453047
}
30463048
)
30473049
_parse_web_class_objects(kwargs)

‎tests/slack_sdk/web/test_chat_stream.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def test_streams_a_long_message(self):
139139
)
140140
],
141141
markdown_text="*",
142+
session_status="processing",
142143
token="xoxb-chat_stream_test_token2",
143144
)
144145

@@ -176,6 +177,7 @@ def test_streams_a_long_message(self):
176177
json.dumps(stop_request.get("chunks")),
177178
'[{"text": "**", "type": "markdown_text"}]',
178179
)
180+
self.assertEqual(stop_request.get("session_status"), "processing")
179181
self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token2")
180182
self.assertEqual(stop_request.get("ts"), "123.123")
181183

‎tests/slack_sdk_async/web/test_async_chat_stream.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ async def test_streams_a_long_message(self):
142142
)
143143
],
144144
markdown_text="*",
145+
session_status="processing",
145146
token="xoxb-chat_stream_test_token2",
146147
)
147148

@@ -179,6 +180,7 @@ async def test_streams_a_long_message(self):
179180
json.dumps(stop_request.get("chunks")),
180181
'[{"text": "**", "type": "markdown_text"}]',
181182
)
183+
self.assertEqual(stop_request.get("session_status"), "processing")
182184
self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token2")
183185
self.assertEqual(stop_request.get("ts"), "123.123")
184186

0 commit comments

Comments
 (0)