mirror of
https://github.com/kc1awv/rrcd.git
synced 2026-06-13 16:23:31 -07:00
fix parted messages to only contain the id of the user leaving a room
This commit is contained in:
+15
-19
@@ -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: <msg-id>,
|
||||
3: <timestamp>,
|
||||
4: <hub-identity-hash>,
|
||||
5: <room-name>,
|
||||
6: [<departed-user-hash>] # body: single-element list
|
||||
}
|
||||
```
|
||||
```python
|
||||
{
|
||||
0: 1,
|
||||
1: T_PARTED,
|
||||
2: <msg-id>,
|
||||
3: <timestamp>,
|
||||
4: <hub-identity-hash>,
|
||||
5: <room-name>,
|
||||
6: [<departed-user-hash>] # 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
|
||||
|
||||
+3
-9
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user