public share UI fix

This commit is contained in:
2025-12-13 14:29:08 +05:00
parent 378a8727e2
commit 62a13a9f45
5 changed files with 149 additions and 61 deletions

View File

@@ -82,6 +82,38 @@ class ConnectionManager:
if not self.active_connections[map_key]:
del self.active_connections[map_key]
async def disconnect_guests(self, map_id: UUID):
"""Disconnect all guest connections (no user_id) on a specific map."""
map_key = str(map_id)
if map_key not in self.active_connections:
return
# Find all guest websockets (uid is None)
connections_to_close = [
websocket for websocket, uid in self.active_connections[map_key]
if uid is None
]
# Close each connection
for websocket in connections_to_close:
try:
await websocket.close(code=1008, reason="Share link revoked")
logger.info(f"Closed WebSocket for guest on map {map_id}")
except Exception as e:
logger.error(f"Error closing WebSocket for guest: {e}")
# Remove from active connections
self.active_connections[map_key] = {
conn for conn in self.active_connections[map_key]
if conn[0] != websocket
}
self.websocket_to_map.pop(websocket, None)
# Clean up empty map entry
if not self.active_connections[map_key]:
del self.active_connections[map_key]
async def broadcast_to_map(self, map_id: UUID, message: dict):
"""Broadcast a message to all clients connected to a specific map."""
map_key = str(map_id)