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

Invalidate members on kick to prevent stale results #4382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zzorba
Copy link
Contributor

@zzorba zzorba commented Dec 6, 2024

Mark the members list as 'invalid' when a user is kicked from a room, to allow a reload to happen the next time members() is invoked.

  • Public API changes documented in changelogs (optional)

Signed-off-by: Daniel Salinas

@zzorba zzorba requested a review from a team as a code owner December 6, 2024 13:41
@zzorba zzorba requested review from andybalaam and removed request for a team December 6, 2024 13:41
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.86%. Comparing base (8865e2f) to head (9502803).
Report is 277 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4382      +/-   ##
==========================================
- Coverage   84.89%   84.86%   -0.03%     
==========================================
  Files         272      272              
  Lines       29167    29149      -18     
==========================================
- Hits        24761    24737      -24     
- Misses       4406     4412       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

Looks good but one question and awaiting confirmation.

@@ -1333,6 +1333,10 @@ impl Room {
{ reason: reason.map(ToOwned::to_owned) }
);
self.client.send(request, None).await?;

// Force future room members reload
self.mark_members_missing();
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, this looks sensible to me, but I'd like to double-check with @poljar .

In the meantime, I would have thought that if we need this in kick_user, we would also need it in ban_user and unban_user too. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, its is almost certainly needed in ban_user also, I will update it there.

For unban_user they are probably not currently in the member list right, after an unban_user you would need to invite them (which would trigger an invalidate)? Unless I'm misunderstanding and the members list contains a list of unbaned users?


// Force future room members reload
self.mark_members_missing();

Copy link
Member

Choose a reason for hiding this comment

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

It would be great to have a test that checks this behaviour too.

@poljar
Copy link
Contributor

poljar commented Dec 6, 2024

Why is this needed, the next sync should give us the updated m.room.member event and the members get processed accordingly.

Surely we don't need to do /members every time we kick|ban|invite a user.

@zzorba
Copy link
Contributor Author

zzorba commented Dec 6, 2024

Yeah, my intent here was to make the members not show invalid data. I'm not seeing the members() get updated for rooms/spaces after someone is kicked (even if I have a timeline syncing data).

@poljar
Copy link
Contributor

poljar commented Dec 10, 2024

Yeah, my intent here was to make the members not show invalid data. I'm not seeing the members() get updated for rooms/spaces after someone is kicked (even if I have a timeline syncing data).

Well that depends on when you call the members() function. They will show the updated state if you call it after the kick has been confirmed by the /sync call to the server.

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.

3 participants