Repository navigation
fix(realtime): address account events by the full user id - #15308
Conversation
fromPayload derived the account channel and user role from the split event name, so a custom user id containing a dot (e.g. john.doe) was truncated to the part before it (john). Account events then went to account.john / user:john, delivering one user's account events to a different user and starving the real owner of its own. Thread the authoritative userId (already carried as the event's userId param) into fromPayload and use it for the channel, the role and the suffix split, instead of parts[1].
|
Review complete. 🟡 1 medium 📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Dotted // src/Appwrite/Messaging/Adapter/Realtime.php
1279 if (
1280 $action !== null
1281 && $parts[0] === 'users'
1282 && ($parts[2] ?? null) !== $action
1283 ) {
1284 $action = null;
1285 }The 🧹 Nitpicks (1) — 🟢 1 low
The change makes the realtime messaging adapter resolve user identity from an explicit
Reviewed commit: e55e4d1 |
🟢 Tier S · Ready to mergeRealtime user events now use the event’s full Latest changes: The new commits use the parsed user-event suffix for the top-level action guard and suffix account channels regardless of how many dot-separated segments the user ID contains, with a regression assertion for dotted-ID create channels.
📂 Walkthrough · 3
✅ Fixed since the last review · 1
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
The top-level-user-event check keyed off parts[2], and the action-channel augmentation off leaf/parent adjacency, both of which a dotted user id shifts. Use the parsed suffix for the top-level check and treat any account.* channel as action-suffixable, so users.john.doe.create emits account.create and account.john.doe.create. Covered in the e2e-adjacent MessagingTest.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
fix(realtime): address account events by the full user id (cherry picked from commit 8cda7d5)
What
Realtime::fromPayload()derived theaccount.<userId>channel and theuser:<userId>role for user events by splitting the event name on.and takingparts[1]. Custom user ids may contain dots, so an event about userjohn.doe(users.john.doe.sessions.…) was addressed to channelaccount.johnand roleuser:john.Effect: a subscriber whose own id is
johnand who subscribes to the defaultaccountchannel receivedjohn.doe's account events — including the user profile payload — whilejohn.doereceived none of their own. The same name-split also mis-computed the event suffix used to decide whether access changed.Fix
The authoritative user id is already carried as the event's
userIdparam (it is passed torealtime->send()for exactly this flow). Thread it intofromPayload()and use it for the account channel, the user role and the suffix split, keepingparts[1]only as a fallback when no id is supplied. Theteams.memberships.deletebranch already uses the payload's userId over the split name — same principle.Finding
Strix #16 (medium, CVSS 4.3). Realtime account events addressed to a truncated user id.
Test
Added
testFromPayloadKeepsDottedUserIdIntactto the existingMessagingTest(which already unit-coversfromPayload): ajohn.doeid keepsaccount.john.doe/user:john.doeand never emits the truncatedaccount.john/user:john. All 70 MessagingTest cases pass;lintandanalyzepass.Part of appwrite-labs/infrastructure#1013