fix: preserve invite workspace bootstrap semantics
This commit is contained in:
parent
8270e5821e
commit
03160a3b37
1 changed files with 22 additions and 11 deletions
|
|
@ -29,6 +29,7 @@ async def provision_workspace_chat(
|
|||
store,
|
||||
auth_mgr,
|
||||
chat_mgr,
|
||||
room_name_override: str | None = None,
|
||||
) -> dict:
|
||||
user = await platform.get_or_create_user(
|
||||
external_id=matrix_user_id,
|
||||
|
|
@ -59,8 +60,9 @@ async def provision_workspace_chat(
|
|||
user_meta["space_id"] = space_id
|
||||
await set_user_meta(store, matrix_user_id, user_meta)
|
||||
|
||||
chat_id = await next_chat_id(store, matrix_user_id)
|
||||
room_name = _default_room_name(chat_id)
|
||||
next_chat_index = int(user_meta.get("next_chat_index", 1))
|
||||
chat_id = f"C{next_chat_index}"
|
||||
room_name = room_name_override or _default_room_name(chat_id)
|
||||
chat_resp = await client.room_create(
|
||||
name=room_name,
|
||||
visibility=RoomVisibility.private,
|
||||
|
|
@ -83,6 +85,10 @@ async def provision_workspace_chat(
|
|||
state_key=chat_room_id,
|
||||
)
|
||||
|
||||
user_meta["space_id"] = space_id
|
||||
user_meta["next_chat_index"] = next_chat_index + 1
|
||||
await set_user_meta(store, matrix_user_id, user_meta)
|
||||
|
||||
await set_room_meta(
|
||||
store,
|
||||
chat_room_id,
|
||||
|
|
@ -122,15 +128,20 @@ async def handle_invite(client: Any, room: Any, event: Any, platform, store, aut
|
|||
if existing and existing.get("space_id"):
|
||||
return
|
||||
|
||||
created = await provision_workspace_chat(
|
||||
client,
|
||||
matrix_user_id,
|
||||
display_name,
|
||||
platform,
|
||||
store,
|
||||
auth_mgr,
|
||||
chat_mgr,
|
||||
)
|
||||
try:
|
||||
created = await provision_workspace_chat(
|
||||
client,
|
||||
matrix_user_id,
|
||||
display_name,
|
||||
platform,
|
||||
store,
|
||||
auth_mgr,
|
||||
chat_mgr,
|
||||
room_name_override="Чат 1",
|
||||
)
|
||||
except RuntimeError as exc:
|
||||
logger.error("invite_workspace_provision_failed", user=matrix_user_id, error=str(exc))
|
||||
return
|
||||
|
||||
welcome = (
|
||||
f"Привет, {created['user'].display_name or matrix_user_id}! Пиши — я здесь.\n\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue