Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bob loses membership to room when he accepts a new invite for a new room #2838

Closed
tak-hntlabs opened this issue Oct 27, 2022 · 1 comment
Closed

Comments

@tak-hntlabs
Copy link
Contributor

tak-hntlabs commented Oct 27, 2022

Background information

  • Dendrite version or git SHA: a2706e6
  • Monolith or Polylith?: Monolith
  • SQLite3 or Postgres?: Postgres
  • Running in Docker?: No
  • go version: 1.19.2
  • Client used (if applicable):

Description

  • What is the problem:

bob is invited to multiple spaces. Bob accepted the invites. Found that his membership was changed to 'Leave' in the earlier spaces that he had just joined.

  • Who is affected:

Users who receive multiple invites, and accepted the invites to join the spaces/ rooms.

  • How is this bug manifesting:

Users' membership changed to 'Leave' in the room that they have just accepted. In order for the bug to manifest, the users must accept another invite.

Steps to reproduce

  • Alice creates roomA and roomB
  • Alice sends both invites to bob
  • Bob starts accepting the invites
  • Bob loses access to roomA when he accepted the invite for roomB

PR with debug notes: #2839

tak-hntlabs added a commit to HereNotThere/dendrite that referenced this issue Nov 1, 2022
neilalexander added a commit that referenced this issue Nov 2, 2022
… marked deleted (#2839)

Proposed fix for issue:
#2838

Suppose bob received invites to spaceA and spaceB.
When Bob joins spaceA, we add an OutputEvent event to retire the invite.
This sets the invite to "deleted" in the database. This makes sense.

The bug is in stream_invites.go. Triggered when bob received a new
invite for spaceB, and does a client sync.

In the block (line 76)
`for roomID := range retiredInvites

   if _, ok := req.Response.Rooms.Invite[roomID]; ok {
	continue
   }

   if _, ok := req.Response.Rooms.Join[roomID]; ok {
	continue
  }
...
` 

Bob is not in either maps even though he had just accepted the invite
for spaceA. Consequently, the spaceA invite is treated as a retired
invite, and a membership Leave event is generated. What bob sees is that
after accepting the invite to spaceB, he lose access to spaceA.


### Pull Request Checklist

<!-- Please read
https://matrix-org.github.io/dendrite/development/contributing before
submitting your pull request -->

* [ ] I have added tests for PR _or_ I have justified why this PR
doesn't need tests.
* [x ] Pull request includes a [sign off below using a legally
identifiable
name](https://matrix-org.github.io/dendrite/development/contributing#sign-off)
_or_ I have already signed off privately

Signed-off-by: `Tak Wai Wong <tak@hntlabs.com>`

Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
@tak-hntlabs
Copy link
Contributor Author

fix merge to main.

tak-hntlabs added a commit to HereNotThere/dendrite that referenced this issue Nov 2, 2022
… marked deleted matrix-org#2838 (#55)

* fix matrix-org#2838 by querying db directly for membership info

* fix lint error

* revert changes and use SelectMembershipForUser directly

* Remove extra membership checks

* Add a comment to explain why the membership check is necessary
tak-hntlabs added a commit to HereNotThere/dendrite that referenced this issue Nov 2, 2022
tak-hntlabs added a commit to HereNotThere/dendrite that referenced this issue Nov 2, 2022
Sync upstream changes to pick up fix for matrix-org#2838
brianathere pushed a commit to HereNotThere/dendrite that referenced this issue Feb 8, 2023
…ix-org#778)

* Latest dendrite main (8c7b274)
* Gating implementation from John and Tak

Fixes for matrix-org#2838 and
matrix-org#2842

Co-authored-by: Tak Wai Wong <tak@hntlabs.com>
brianathere added a commit to HereNotThere/dendrite that referenced this issue Feb 8, 2023
Pull the fix for matrix-org#2838 into
the dendrite subtree. Includes latest dendrite main.

Signed-off-by: `Devon Hudson <devonhudson@librem.one>`
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Brian Meek <brian@hntlabs.com>
Signed-off-by: Austin Ellis <austin@hntlabs.com>
Signed-off-by: `Rubin Poster <rubinposter@gmail.com>`
Signed-off-by: `ash lea <example@thisismyactual.email>`
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
Co-authored-by: devonh <devon.dmytro@gmail.com>
Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com>
Co-authored-by: Ashley Nelson <fant@shley.email>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brian Meek <brian@hntlabs.com>
Co-authored-by: Tak Wai Wong <takwaiw@gmail.com>
Co-authored-by: Jean Lucas <jean@4ray.co>
Co-authored-by: Kabir Kwatra <kabir@kwatra.me>
Co-authored-by: sergekh2 <gitgitgit@khorun.com>
Co-authored-by: texuf <texuf.eth@gmail.com>
Co-authored-by: kegsay <kegan@matrix.org>
Co-authored-by: Brian Meek <brian@here.video>
Co-authored-by: John Terzis <john.c.terzis@gmail.com>
Co-authored-by: John Terzis <john@hntlabs.com>
Co-authored-by: Kerem <kerem.kazan@gmail.com>
Co-authored-by: Neboer <43609792+Neboer@users.noreply.github.com>
Co-authored-by: X. Ding <dingsm@gmail.com>
Co-authored-by: dxl <dxl@plotbridge.com>
Co-authored-by: ash lea <ashkitten@users.noreply.github.com>
Co-authored-by: 0x1a8510f2 <admin@0x1a8510f2.space>
Co-authored-by: Till Faelligen <tfaelligen@gmail.com>
Co-authored-by: Till Faelligen <davidf@element.io>
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

No branches or pull requests

1 participant