diff --git a/docketeer-slack/src/docketeer_slack/client.py b/docketeer-slack/src/docketeer_slack/client.py index 0e8eaee..0e74045 100644 --- a/docketeer-slack/src/docketeer_slack/client.py +++ b/docketeer-slack/src/docketeer_slack/client.py @@ -418,7 +418,7 @@ async def start_reply_stream( } if self._team_id: data["recipient_team_id"] = self._team_id - if msg.kind is RoomKind.direct and msg.user_id: + if msg.user_id: data["recipient_user_id"] = msg.user_id payload = await self._api_post( "chat.startStream", @@ -432,7 +432,7 @@ async def start_reply_stream( channel_id=msg.room_id, stream_ts=stream_ts, thread_id=thread_id, - user_id=msg.user_id if msg.kind is RoomKind.direct else "", + user_id=msg.user_id, ) async def append_reply_stream(self, stream: Any, text: str) -> None: diff --git a/docketeer-slack/tests/test_rest.py b/docketeer-slack/tests/test_rest.py index 879df99..055de0a 100644 --- a/docketeer-slack/tests/test_rest.py +++ b/docketeer-slack/tests/test_rest.py @@ -50,14 +50,14 @@ async def test_start_reply_stream_channel(slack_client: SlackClient): channel_id="C1", stream_ts="1718.1", thread_id="1718", - user_id="", + user_id="U1", ) body = route.calls[0].request.content.decode() assert "channel=C1" in body assert "thread_ts=1718" in body assert "markdown_text=hello" in body assert "recipient_team_id=" in body - assert "recipient_user_id" not in body + assert "recipient_user_id=U1" in body @respx.mock @@ -103,6 +103,33 @@ async def test_start_reply_stream_without_team_id(slack_client: SlackClient): assert "recipient_team_id" not in body +@respx.mock +async def test_start_reply_stream_without_user_id(slack_client: SlackClient): + route = respx.post("https://slack.com/api/chat.startStream") + route.mock(return_value=httpx.Response(200, json={"ok": True, "ts": "1718.1"})) + stream = await slack_client.start_reply_stream( + IncomingMessage( + message_id="C1:1718", + user_id="", + username="alice", + display_name="Alice", + text="hi", + room_id="C1", + kind=RoomKind.public, + ), + "1718", + "hello", + ) + assert stream == SlackReplyStream( + channel_id="C1", + stream_ts="1718.1", + thread_id="1718", + user_id="", + ) + body = route.calls[0].request.content.decode() + assert "recipient_user_id" not in body + + @respx.mock async def test_start_reply_stream_returns_none_without_thread_or_text( slack_client: SlackClient,