From 5e44961306e09fab814682c35c649221cc884a18 Mon Sep 17 00:00:00 2001 From: kc1awv Date: Fri, 9 Jan 2026 10:21:59 -0500 Subject: [PATCH] fix parted messages to only contain the id of the user leaving a room --- EX1-RRCD.md | 34 +++++++++++++++------------------- rrcd/router.py | 12 +++--------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/EX1-RRCD.md b/EX1-RRCD.md index 40cc59a..be91f89 100644 --- a/EX1-RRCD.md +++ b/EX1-RRCD.md @@ -315,25 +315,21 @@ When a user joins a room: ### PART Behavior -When a user leaves a room: +When a user leaves a room, all users (including the departing user) receive a +`PARTED` message containing **only** the departing user's identity hash (if +`include_joined_member_list` is enabled). -1. **Parting user receives**: A `PARTED` message containing the list of - remaining room members (if `include_joined_member_list` is enabled). - -2. **Remaining room members receive**: A `PARTED` message containing **only** - the identity hash of the user who just left. - - ```python - { - 0: 1, - 1: T_PARTED, - 2: , - 3: , - 4: , - 5: , - 6: [] # body: single-element list - } - ``` +```python +{ + 0: 1, + 1: T_PARTED, + 2: , + 3: , + 4: , + 5: , + 6: [] # body: single-element list +} +``` ### Configuration @@ -347,7 +343,7 @@ When disabled, all `JOINED` and `PARTED` messages have `null` or empty bodies. - **JOINED bodies** may contain either a full member list (multiple hashes) or a single hash. Clients should handle both cases. -- **PARTED bodies** follow the same pattern. +- **PARTED bodies** always contain a single hash (the departing user's identity). - The message source (`K_SRC`) is always the hub's identity hash, not the joining/parting user. - This extension allows clients to maintain accurate room member lists without diff --git a/rrcd/router.py b/rrcd/router.py index a9caae3..9e7429a 100644 --- a/rrcd/router.py +++ b/rrcd/router.py @@ -614,15 +614,9 @@ class MessageRouter: outgoing, member_link, member_notification_payload ) - parted_body = None - if self.hub.config.include_joined_member_list: - members: list[bytes] = [] - for member_link in self.hub.room_manager.get_room_members(r): - s = self.hub.session_manager.sessions.get(member_link) - ph = s.get("peer") if s else None - if isinstance(ph, (bytes, bytearray)): - members.append(bytes(ph)) - parted_body = members + parted_body = ( + [peer_hash] if self.hub.config.include_joined_member_list else None + ) if self.hub.identity is not None: parted = make_envelope(