fix(01-05): align matrix confirmation scope with user and room

- carry Matrix room_id through command callbacks
- persist pending confirmations by user_id and room_id
This commit is contained in:
Mikhail Putilovskij 2026-04-03 12:26:32 +03:00
parent 97a3dc35ea
commit 35695e043f
4 changed files with 62 additions and 25 deletions

View file

@ -56,7 +56,7 @@ def extract_attachments(event: Any) -> list[Attachment]:
return []
def from_command(body: str, sender: str, chat_id: str) -> IncomingEvent:
def from_command(body: str, sender: str, chat_id: str, room_id: str | None = None) -> IncomingEvent:
raw = body.lstrip("!").strip()
parts = raw.split()
command = parts[0].lower() if parts else ""
@ -69,7 +69,11 @@ def from_command(body: str, sender: str, chat_id: str) -> IncomingEvent:
platform=PLATFORM,
chat_id=chat_id,
action=action,
payload={"source": "command", "command": command},
payload={
"source": "command",
"command": command,
**({"room_id": room_id} if room_id is not None else {}),
},
)
aliases = {
@ -132,7 +136,7 @@ def from_room_event(event: Any, room_id: str, chat_id: str) -> IncomingEvent | N
body = (getattr(event, "body", None) or "").strip()
sender = getattr(event, "sender", "")
if body.startswith("!"):
return from_command(body, sender=sender, chat_id=chat_id)
return from_command(body, sender=sender, chat_id=chat_id, room_id=room_id)
return IncomingMessage(
user_id=sender,
platform=PLATFORM,