feat: support shared-workspace file flow for matrix
This commit is contained in:
parent
323a6d3144
commit
6422c7db58
18 changed files with 871 additions and 80 deletions
|
|
@ -9,7 +9,7 @@ from adapter.matrix.handlers.confirm import make_handle_cancel, make_handle_conf
|
|||
from adapter.matrix.store import get_pending_confirm, set_room_meta
|
||||
from core.auth import AuthManager
|
||||
from core.chat import ChatManager
|
||||
from core.protocol import OutgoingUI, UIButton
|
||||
from core.protocol import Attachment, OutgoingMessage, OutgoingUI, UIButton
|
||||
from core.settings import SettingsManager
|
||||
from core.store import InMemoryStore
|
||||
from sdk.mock import MockPlatformClient
|
||||
|
|
@ -156,3 +156,39 @@ async def test_outgoing_ui_no_round_trip_uses_user_and_room_scope():
|
|||
assert "отменено" in result[0].text.lower()
|
||||
assert await get_pending_confirm(store, "@alice:example.org", "!confirm:example.org") is None
|
||||
assert await get_pending_confirm(store, "@bob:example.org", "!other:example.org") is not None
|
||||
|
||||
|
||||
async def test_send_outgoing_uploads_workspace_file_attachment(tmp_path, monkeypatch):
|
||||
workspace_file = tmp_path / "surfaces" / "matrix" / "alice" / "room" / "inbox" / "result.txt"
|
||||
workspace_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
workspace_file.write_text("ready")
|
||||
monkeypatch.setenv("SURFACES_WORKSPACE_DIR", str(tmp_path))
|
||||
|
||||
client = SimpleNamespace(
|
||||
upload=AsyncMock(return_value=(SimpleNamespace(content_uri="mxc://server/file"), {})),
|
||||
room_send=AsyncMock(),
|
||||
)
|
||||
|
||||
await send_outgoing(
|
||||
client,
|
||||
"!room:example.org",
|
||||
OutgoingMessage(
|
||||
chat_id="!room:example.org",
|
||||
text="Файл готов",
|
||||
attachments=[
|
||||
Attachment(
|
||||
type="document",
|
||||
filename="result.txt",
|
||||
mime_type="text/plain",
|
||||
workspace_path="surfaces/matrix/alice/room/inbox/result.txt",
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
client.upload.assert_awaited_once()
|
||||
client.room_send.assert_awaited()
|
||||
assert client.room_send.await_args_list[0].args[2]["body"] == "Файл готов"
|
||||
file_call = client.room_send.await_args_list[1]
|
||||
assert file_call.args[2]["msgtype"] == "m.file"
|
||||
assert file_call.args[2]["url"] == "mxc://server/file"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue