feat: inject sessionKey for remote federation sessions

- Remote sessions now include sessionKey field formatted as 'remoteId:name'
- Local sessions are unchanged (no sessionKey) as they never collide
- Prevents name collisions between local and remote sessions with identical names
- Added tests: test_federation_sessions_local_sessions_have_no_session_key
               test_federation_sessions_remote_sessions_have_session_key
This commit is contained in:
Brian Krabach
2026-04-04 06:36:24 -07:00
parent 28aaf3d484
commit 42142c0954
2 changed files with 132 additions and 2 deletions
+7 -2
View File
@@ -913,9 +913,14 @@ async def federation_sessions(request: Request) -> list[dict]:
]
resp.raise_for_status()
sessions = resp.json()
# Tag each session with deviceName and remoteId
# Tag each session with deviceName, remoteId, and unique sessionKey
return [
{**s, "deviceName": remote_name, "remoteId": remote_id}
{
**s,
"deviceName": remote_name,
"remoteId": remote_id,
"sessionKey": f"{remote_id}:{s.get('name', '')}",
}
for s in sessions
]
except httpx.HTTPStatusError: