Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docketeer-slack/src/docketeer_slack/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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:
Expand Down
31 changes: 29 additions & 2 deletions docketeer-slack/tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down