|
@@ -3723,6 +3723,54 @@ class TestPluginToolHandlers:
|
|
|
assert result["success"] is True
|
|
assert result["success"] is True
|
|
|
assert client.post_message.await_args.kwargs["thread_root_event_id"] == "msg-9"
|
|
assert client.post_message.await_args.kwargs["thread_root_event_id"] == "msg-9"
|
|
|
|
|
|
|
|
|
|
+ async def test_send_room_follows_a_thread_it_replied_into(self):
|
|
|
|
|
+ """Replying into someone else's thread makes the bot a participant.
|
|
|
|
|
+ Chatto only delivers a thread's replies to an account that follows it
|
|
|
|
|
+ (or was mentioned in it directly), so an unfollowed reply can end the
|
|
|
|
|
+ conversation the agent just joined — the adapter's own send() follows
|
|
|
|
|
+ every thread it posts into, and the tool has to agree."""
|
|
|
|
|
+ room = _make_room("room-1", "Ops", RoomKind.CHANNEL)
|
|
|
|
|
+ client = self._stub_client()
|
|
|
|
|
+ client.get_room = AsyncMock(return_value=_make_room_state(room))
|
|
|
|
|
+ client.get_message = AsyncMock(
|
|
|
|
|
+ return_value=_make_message(message_id="msg-9", room_id="room-1")
|
|
|
|
|
+ )
|
|
|
|
|
+ result, _, _ = await self._run(
|
|
|
|
|
+ _handle_chatto_send_room,
|
|
|
|
|
+ {"room_id": "room-1", "message": "hi", "thread_root_event_id": "msg-9"},
|
|
|
|
|
+ client=client,
|
|
|
|
|
+ optional_mention_rooms="room-1",
|
|
|
|
|
+ )
|
|
|
|
|
+ assert result["success"] is True
|
|
|
|
|
+ client.follow_thread.assert_awaited_once_with("room-1", "msg-9")
|
|
|
|
|
+
|
|
|
|
|
+ async def test_send_room_follows_a_thread_it_created(self):
|
|
|
|
|
+ room = _make_room("room-1", "Ops", RoomKind.CHANNEL)
|
|
|
|
|
+ client = self._stub_client()
|
|
|
|
|
+ client.get_room = AsyncMock(return_value=_make_room_state(room))
|
|
|
|
|
+ result, _, _ = await self._run(
|
|
|
|
|
+ _handle_chatto_send_room,
|
|
|
|
|
+ {"room_id": "room-1", "message": "hi", "create_thread": True},
|
|
|
|
|
+ client=client,
|
|
|
|
|
+ optional_mention_rooms="room-1",
|
|
|
|
|
+ )
|
|
|
|
|
+ assert result["success"] is True
|
|
|
|
|
+ client.follow_thread.assert_awaited_once_with("room-1", "msg-1")
|
|
|
|
|
+
|
|
|
|
|
+ async def test_send_room_does_not_follow_a_plain_room_message(self):
|
|
|
|
|
+ """Nothing to follow: a message that opens no thread and joins none."""
|
|
|
|
|
+ room = _make_room("room-1", "Ops", RoomKind.CHANNEL)
|
|
|
|
|
+ client = self._stub_client()
|
|
|
|
|
+ client.get_room = AsyncMock(return_value=_make_room_state(room))
|
|
|
|
|
+ result, _, _ = await self._run(
|
|
|
|
|
+ _handle_chatto_send_room,
|
|
|
|
|
+ {"room_id": "room-1", "message": "hi"},
|
|
|
|
|
+ client=client,
|
|
|
|
|
+ optional_mention_rooms="room-1",
|
|
|
|
|
+ )
|
|
|
|
|
+ assert result["success"] is True
|
|
|
|
|
+ client.follow_thread.assert_not_awaited()
|
|
|
|
|
+
|
|
|
# -- chunked delivery --
|
|
# -- chunked delivery --
|
|
|
|
|
|
|
|
async def test_send_room_reports_a_partial_delivery(self):
|
|
async def test_send_room_reports_a_partial_delivery(self):
|