Skip to content

fix(realtime): deliver membership delete events to the removed member - #14210

Merged
HarshMN2345 merged 8 commits into
mainfrom
cursor/membership-realtime-delete-98fa
Oct 12, 2026
Merged

HarshMN2345 merged 8 commits into
mainfrom
cursor/membership-realtime-delete-98fa

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Fixes #13768. Deleting a team membership did not emit a realtime delete event to the removed member's client SDK. Membership create already did.

Membership events are published only to team:{teamId}. The realtime worker treats membership changes as permission changes and re-resolves that user's open connections before fan-out. On create, that re-resolve grants the team role, so the event matches. On delete, the team role is already gone, so the same connection never matches and the client receives nothing.

Realtime::fromPayload() now also addresses teams.{teamId}.memberships.{membershipId}.delete to the membership subject's user:{userId} (taken from the membership payload). Teammates still match the team role. Create and update stay team-only.

Test Plan

  • php vendor/bin/phpunit --no-configuration --bootstrap vendor/autoload.php tests/unit/Messaging/MessagingTest.php --filter testMembershipDeleteReachesSubjectAfterTeamRoleIsRevoked

  • The new test checks that a delete event includes the subject user role and the team role, that a connection subscribed only as that user (the post-revocation state) receives it, that a remaining teammate receives it, and that an unrelated user does not. Create and update are still addressed only to the team role.

  • Full tests/unit/Messaging/MessagingTest.php (40 tests) passed.

  • tests/e2e/Services/Realtime/RealtimeCustomClientTest.php::testChannelMembershipsDelete comes from fix(realtime): deliver membership delete event to removed member #13780 by ItsRoy69, merged into this branch. It subscribes the member to memberships, adds and then deletes their membership, and expects both the create and the delete event. fix(realtime): deliver membership delete event to removed member #13780's worker change (collecting receivers before the connection rebuild and scanning again for other permission changes) is not kept: with the delete event addressed to the member's user role, the single scan after the rebuild already reaches them.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?
Open in Web Open in Cursor 

ItsRoy69 and others added 3 commits September 20, 2026 19:51
The delete is published only to the team role, and the realtime worker
re-resolves the removed member before fan-out, so that client no longer
matches. Include the subject's user role on the delete event.
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/membership-realtime-delete-98fa (after).

Metric Before After Change
🚀 Requests/sec 189.11 204.6 🟢 +8.2%
⏱️ Latency P50 90.61 ms 85.05 ms 🟢 -6.1%
⏱️ Latency P95 212.66 ms 194.92 ms 🟢 -8.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 85.05 194.92 12,654 204.6 -17.74
Account 160.53 308.27 666 11.05 -27.84
TablesDB 83.28 153.39 6,882 112.84 -7.03
Storage 76.81 161 3,330 56.86 -15.74
Functions 124.22 226.66 1,776 31.1 -60.99

Top API waits (after)

API request Max wait (ms)
account.name.update 537.71
account.prefs.update 424.12
functions.variables.update 411.17
tablesdb.rows.delete 405.02
functions.variables.create 374.61

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost

ghost commented Oct 7, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Membership delete events include the removed member's user role as well as the team role, so the member can receive the event after their team access is revoked while teammates continue to receive it. Unit coverage checks routing for the removed member, teammates, and unrelated users, and an end-to-end test covers membership creation and deletion delivery. The latest change clarifies how the worker refreshes subscriptions before event matching.

Latest changes: Updated the routing comment to explain that the worker refreshes the member's subscriptions with current roles before matching the delete event.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
src/Appwrite/Messaging/Adapter/Realtime.php Adds the removed member's user role to membership delete event routing alongside the team role.
tests/unit/Messaging/MessagingTest.php Verifies membership delete delivery to the removed member and teammates, excludes unrelated users, and preserves team-only create/update routing.
tests/e2e/Services/Realtime/RealtimeCustomClientTest.php Covers membership create and delete events reaching the member's client.

Merged main (11029f8); no changes to this PR's code since d6d6d4e · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

HarshMN2345 and others added 3 commits October 12, 2026 13:33
…e-event-13768

fix(realtime): deliver membership delete event to removed member
…uild

Membership delete events now carry the removed member's user role, so the worker no longer needs to collect receivers before rebuilding connections or scan the tree twice for other permission changes.
@HarshMN2345
HarshMN2345 marked this pull request as ready for review October 12, 2026 08:24
@luxor-code-review

luxor-code-review Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The change addresses a gap where a removed team member's connection re-resolution strips their team:{teamId} role before the delete event fans out, so the event never reached them. The fix appends the affected user's personal role to the delete event's roles in the realtime adapter, keeping the event addressable to that user without granting team access. Coverage is added at both unit and e2e levels.

Files Change
src/Appwrite/Messaging/Adapter/Realtime.php Appends user:{userId} to roles for team membership delete events so removed members receive their own deletion event.
tests/unit/Messaging/MessagingTest.php Adds a unit test asserting delete events include the user role while create/update do not.
tests/e2e/Services/Realtime/RealtimeCustomClientTest.php Adds an e2e websocket test verifying the removed member receives the delete event via memberships channels.

Reviewed commit: c24ef7a

HarshMN2345 and others added 2 commits October 12, 2026 14:06
@HarshMN2345
HarshMN2345 merged commit 78389e9 into main Oct 12, 2026
18 checks passed
abnegate added a commit that referenced this pull request Oct 12, 2026
Brings in Android passkey origins (#14353) and membership delete
events for the removed member (#14210). Ported to database 8.0: the
platforms fingerprints attribute as Attribute::string, and Id in place
of ID in the realtime adapter and the new tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Membership realtime delete event not properly firing on client sdks

3 participants