-
Notifications
You must be signed in to change notification settings - Fork 362
Verify membership when test if name is ambiguous #5780
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
base: main
Are you sure you want to change the base?
Verify membership when test if name is ambiguous #5780
Conversation
|
It's pretty straightforward but should I had some tests? |
b1cd305 to
47488fd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5780 +/- ##
==========================================
+ Coverage 88.45% 88.47% +0.02%
==========================================
Files 360 360
Lines 100322 100400 +78
Branches 100322 100400 +78
==========================================
+ Hits 88737 88830 +93
+ Misses 7420 7403 -17
- Partials 4165 4167 +2 ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #5780 will not alter performanceComparing Summary
|
| .is_some_and(|s| is_display_name_ambiguous(&display_name, s)); | ||
| let membership = event.membership(); | ||
| let display_name_ambiguous = users_display_names.get(&display_name).is_some_and(|s| { | ||
| is_display_name_ambiguous(&display_name, s) && *membership != MembershipState::Leave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we don't want to disambiguate the name of a left user, why is that? I see the AmbiguityCache has a concept of active members so what are we trying to achieve here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because of the spec. It only sees member with an join or an invite membership as needing disambiguation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the code to follow more precisely the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not updating is_display_name_ambiguous to include this membership constraint? It seems to be really part of it.
bnjbvr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! Can you add a test please? Ideally it would show the case that's failing on main (but supposed to work), and that would be working with your patch now.
| is_display_name_ambiguous(&display_name, s) | ||
| && (*membership == MembershipState::Join || *membership == MembershipState::Invite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write the second part with a match statement, please? This will make it so that we explicitly handle all the membership cases, and we don't forget to think about handling it, would we have a new membership kind later on.
if !is_display_name_ambiguous(&display_name, s) {
return false;
}
match *membership {
// handle all variants explicitly here
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's clearly worth adding this logic inside is_display_name_ambiguous.
6314fbb to
7a93c57
Compare
|
@bnjbvr matrix-rust-sdk/crates/matrix-sdk-base/src/room/members.rs Lines 615 to 622 in 7a93c57
Unless I misunderstood, the name should be here ambiguous and the test should on line 621 should not be failing. Should I make a new issue ? |
|
It sounds like the code you've changed introduced a regression, so, no, we can't merge this as is and open a new issue. Instead, one should investigate the issue and attempt to fix it :) |
|
So i checked, and it seems that when using saving_changes to store the member events in MemoryStore, the HashMap |
|
@bnjbvr |
|
I made a mistake anyway, I should check the membership of every RoomMember with the same displayname, I'm getting back into IT. |
b932ac2 to
1f759a6
Compare
52fad95 to
2892f60
Compare
|
@poljar Should I make an issue regarding this?
|
|
Just my 2 cents, but why don't we keep only the active members in the display names cache, rather than having unnecessary data in it, and then use a list of active members to filter it? |
|
tbh that would make sense, but that would be a breaking change. |
|
Why would this be a breaking change? Isn't this data used only internally when building a |
Hywan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice contribution, thank you.
I think we should merge the logic inside is_display_name_ambiguous to make less error-prone. What do you think?
| .is_some_and(|s| is_display_name_ambiguous(&display_name, s)); | ||
| let membership = event.membership(); | ||
| let display_name_ambiguous = users_display_names.get(&display_name).is_some_and(|s| { | ||
| is_display_name_ambiguous(&display_name, s) && *membership != MembershipState::Leave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not updating is_display_name_ambiguous to include this membership constraint? It seems to be really part of it.
| is_display_name_ambiguous(&display_name, s) | ||
| && (*membership == MembershipState::Join || *membership == MembershipState::Invite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's clearly worth adding this logic inside is_display_name_ambiguous.
| let display_name = event.display_name(); | ||
| let membership = event.membership(); | ||
|
|
||
| println!("{:?} {:?}", users_display_names, &display_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will update is_display_name_ambiguous to take a MemberEvent instead of a string
|
I messed up the history big will force push because of it. |
cce393c to
2892f60
Compare
Verify if the membership is not Leave when checking if a name in a room is ambiguous.
Signed-off-by:
multi
Fix #5774