fix(01-01): stop auto-registering unknown matrix rooms
- resolve known room chat ids from stored metadata only - return an explicit unregistered fallback and warn in logs
This commit is contained in:
parent
84111ca524
commit
c8770da345
1 changed files with 7 additions and 13 deletions
|
|
@ -1,23 +1,17 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from adapter.matrix.store import get_room_meta, next_chat_id, set_room_meta
|
import structlog
|
||||||
|
|
||||||
|
from adapter.matrix.store import get_room_meta
|
||||||
from core.store import StateStore
|
from core.store import StateStore
|
||||||
|
|
||||||
|
logger = structlog.get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def resolve_chat_id(store: StateStore, room_id: str, matrix_user_id: str) -> str:
|
async def resolve_chat_id(store: StateStore, room_id: str, matrix_user_id: str) -> str:
|
||||||
meta = await get_room_meta(store, room_id)
|
meta = await get_room_meta(store, room_id)
|
||||||
if meta and meta.get("chat_id"):
|
if meta and meta.get("chat_id"):
|
||||||
return meta["chat_id"]
|
return meta["chat_id"]
|
||||||
|
|
||||||
chat_id = await next_chat_id(store, matrix_user_id)
|
logger.warning("unregistered_room", room_id=room_id, user=matrix_user_id)
|
||||||
await set_room_meta(
|
return f"unregistered:{room_id}"
|
||||||
store,
|
|
||||||
room_id,
|
|
||||||
{
|
|
||||||
"room_type": "chat",
|
|
||||||
"chat_id": chat_id,
|
|
||||||
"display_name": f"Чат {chat_id}",
|
|
||||||
"matrix_user_id": matrix_user_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
return chat_id
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue