feat(matrix): land QA follow-ups and refresh docs
- harden Matrix onboarding/chat lifecycle after manual QA - refresh README and Matrix docs to match current behavior - add local ignores for runtime artifacts and include current planning/report docs Closes #7 Closes #9 Closes #14
This commit is contained in:
parent
7fce4c9b3e
commit
6ced154124
35 changed files with 8380 additions and 67 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
import structlog
|
||||
from typing import Any
|
||||
|
||||
from nio.api import RoomVisibility
|
||||
from nio.responses import RoomCreateError
|
||||
|
||||
from adapter.matrix.store import (
|
||||
|
|
@ -15,7 +16,7 @@ from adapter.matrix.store import (
|
|||
logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
async def handle_invite(client: Any, room: Any, event: Any, platform, store, auth_mgr) -> None:
|
||||
async def handle_invite(client: Any, room: Any, event: Any, platform, store, auth_mgr, chat_mgr) -> None:
|
||||
matrix_user_id = getattr(event, "sender", "")
|
||||
display_name = getattr(room, "display_name", None) or matrix_user_id
|
||||
|
||||
|
|
@ -37,7 +38,8 @@ async def handle_invite(client: Any, room: Any, event: Any, platform, store, aut
|
|||
space_resp = await client.room_create(
|
||||
name=f"Lambda — {display_name}",
|
||||
space=True,
|
||||
visibility="private",
|
||||
visibility=RoomVisibility.private,
|
||||
invite=[matrix_user_id],
|
||||
)
|
||||
if isinstance(space_resp, RoomCreateError):
|
||||
logger.error(
|
||||
|
|
@ -50,8 +52,9 @@ async def handle_invite(client: Any, room: Any, event: Any, platform, store, aut
|
|||
|
||||
chat_resp = await client.room_create(
|
||||
name="Чат 1",
|
||||
visibility="private",
|
||||
visibility=RoomVisibility.private,
|
||||
is_direct=False,
|
||||
invite=[matrix_user_id],
|
||||
)
|
||||
if isinstance(chat_resp, RoomCreateError):
|
||||
logger.error(
|
||||
|
|
@ -69,9 +72,6 @@ async def handle_invite(client: Any, room: Any, event: Any, platform, store, aut
|
|||
state_key=chat_room_id,
|
||||
)
|
||||
|
||||
await client.room_invite(space_id, matrix_user_id)
|
||||
await client.room_invite(chat_room_id, matrix_user_id)
|
||||
|
||||
chat_id = await next_chat_id(store, matrix_user_id)
|
||||
|
||||
user_meta = await get_user_meta(store, matrix_user_id) or {}
|
||||
|
|
@ -89,6 +89,13 @@ async def handle_invite(client: Any, room: Any, event: Any, platform, store, aut
|
|||
"space_id": space_id,
|
||||
},
|
||||
)
|
||||
await chat_mgr.get_or_create(
|
||||
user_id=matrix_user_id,
|
||||
chat_id=chat_id,
|
||||
platform="matrix",
|
||||
surface_ref=chat_room_id,
|
||||
name="Чат 1",
|
||||
)
|
||||
|
||||
welcome = (
|
||||
f"Привет, {user.display_name or matrix_user_id}! Пиши — я здесь.\n\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue