Fix #14: broadcast_message excludes by session_id, not slug (multi-tab support)
Some checks failed
Deploy Tracker / deploy (push) Failing after 4s
Some checks failed
Deploy Tracker / deploy (push) Failing after 4s
This commit is contained in:
parent
8a54a2d609
commit
e842149a23
@ -330,7 +330,7 @@ async def _handle_chat_send(session_id: str, data: dict):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if project_id:
|
if project_id:
|
||||||
await manager.broadcast_message(project_id, msg_data, author_slug=slug)
|
await manager.broadcast_message(project_id, msg_data, author_slug=slug, author_session_id=session_id)
|
||||||
else:
|
else:
|
||||||
await manager.broadcast_all(
|
await manager.broadcast_all(
|
||||||
{"type": WSEventType.MESSAGE_NEW, "data": msg_data},
|
{"type": WSEventType.MESSAGE_NEW, "data": msg_data},
|
||||||
|
|||||||
@ -79,11 +79,11 @@ class ConnectionManager:
|
|||||||
except Exception:
|
except Exception:
|
||||||
await self.disconnect(client.session_id)
|
await self.disconnect(client.session_id)
|
||||||
|
|
||||||
async def broadcast_message(self, project_id: str, message: dict, author_slug: str):
|
async def broadcast_message(self, project_id: str, message: dict, author_slug: str, author_session_id: str | None = None):
|
||||||
"""Broadcast message.new. Humans get everything, agents filtered.
|
"""Broadcast message.new. Humans get everything, agents filtered.
|
||||||
|
|
||||||
Filtering for agents:
|
Filtering for agents:
|
||||||
- Skip own messages (author_slug == client slug)
|
- Skip author's session (by session_id if available, else by slug)
|
||||||
- Skip if not subscribed to project
|
- Skip if not subscribed to project
|
||||||
- Skip if chat_listen == "none"
|
- Skip if chat_listen == "none"
|
||||||
- If chat_listen == "mentions": only if @slug in mentions
|
- If chat_listen == "mentions": only if @slug in mentions
|
||||||
@ -95,7 +95,10 @@ class ConnectionManager:
|
|||||||
payload = {"type": WSEventType.MESSAGE_NEW, "data": message}
|
payload = {"type": WSEventType.MESSAGE_NEW, "data": message}
|
||||||
|
|
||||||
for session_id, client in list(self.sessions.items()):
|
for session_id, client in list(self.sessions.items()):
|
||||||
if client.member_slug == author_slug:
|
# Skip only the sending session, not all sessions of the same user
|
||||||
|
if author_session_id and session_id == author_session_id:
|
||||||
|
continue
|
||||||
|
if not author_session_id and client.member_slug == author_slug:
|
||||||
continue
|
continue
|
||||||
# Humans/bridges get ALL messages
|
# Humans/bridges get ALL messages
|
||||||
if client.member_type in (MemberType.HUMAN, MemberType.BRIDGE):
|
if client.member_type in (MemberType.HUMAN, MemberType.BRIDGE):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user