[WPB-22549] fix logic around members with user type app and no user identity#5029
[WPB-22549] fix logic around members with user type app and no user identity#5029
Conversation
b150ea4 to
f7459ee
Compare
60f0725 to
3bbfc76
Compare
|
one2one conversations work! here is a shell script that may reproduce just the "member opens conv with app" case (not thoroughly tested): |
|
regular user creating a team group conv with an app does not work. 403 instead of success when sending the MLS add commit. again, shell script for the "regular contacts app" case: Channels have a similar problem. |
59d450a to
92bd4ec
Compare
... even though they have no identity.
4782849 to
c1a8a2f
Compare
| -- these tests are structurally very similar, and we could reduce the | ||
| -- redundancy further. | ||
| -- | ||
| -- TODO: what about federation? |
There was a problem hiding this comment.
can we keep these? i really want to address them in the next PR.
There was a problem hiding this comment.
Why next PR?
Would you remove these if your next PR gets delayed due to something else?
There was a problem hiding this comment.
client devs are waiting for this PR to land. i changed it into FUTUREWORK and will either get to it or not, ok?
There was a problem hiding this comment.
This is the relevant change in this PR. It allows apps to be found even though they have no identity. I also reworded the whole thing in the vaining hope it's now more readable.
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where app users (which don't have a userIdentity) were incorrectly filtered out by the getAccountsByImpl function when includeUsersWithoutIdentity = False. The fix refactors the filtering logic to explicitly allow users with userType == UserTypeApp regardless of the includeUsersWithoutIdentity flag, since apps are valid users that should always be included.
Changes:
- Refactored user filtering logic in
getAccountsByImplto correctly handle app users without identities - Expanded test coverage for conversations involving app users across multiple conversation types (Proteus, one-to-one, team, and channel)
- Removed redundant app testing code from
Test/Apps.hsthat was moved to more comprehensive tests
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
libs/wire-subsystems/src/Wire/UserSubsystem/Interpreter.hs |
Core fix: refactored filter logic to ensure app users are included regardless of includeUsersWithoutIdentity flag |
libs/wire-subsystems/src/Wire/BrigAPIAccess/Rpc.hs |
Added FUTUREWORK comment questioning necessity of getUsersByVariousKeys function |
integration/test/Test/Conversation.hs |
Significantly expanded test coverage with structured tests for apps in different conversation types; added ConvType enum and parameterized test function |
integration/test/Test/Apps.hs |
Removed duplicate test code for one2one conversations and key package claiming that's now covered in Test/Conversation.hs |
integration/test/MLS/Util.hs |
Added Eq and Show derivations to MessagePackage for better test support |
changelog.d/3-bug-fixes/WPB-22549-fix-brig-lookup-users |
Added changelog entry documenting the bug fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| resp.status `shouldMatchInt` 404 | ||
| resp.json %. "label" `shouldMatch` "not-found" | ||
| resp.status `shouldMatchInt` 403 | ||
| resp.json %. "label" `shouldMatch` "same-binding-team-users" |
There was a problem hiding this comment.
not sure where the 404 comes from, i think it's a git artefact from an earlier, wrong version of this test.
There was a problem hiding this comment.
Its an artefact of apps getting skipped when using UserSubsystem.getAccountsBy.
There was a problem hiding this comment.
No, that changes in this PR: getAccountsBy now returns apps even if they have no identity.
| resp.status `shouldMatchInt` 404 | ||
| resp.json %. "label" `shouldMatch` "not-found" | ||
| resp.status `shouldMatchInt` 403 | ||
| resp.json %. "label" `shouldMatch` "same-binding-team-users" |
There was a problem hiding this comment.
Its an artefact of apps getting skipped when using UserSubsystem.getAccountsBy.
| -- these tests are structurally very similar, and we could reduce the | ||
| -- redundancy further. | ||
| -- | ||
| -- TODO: what about federation? |
There was a problem hiding this comment.
Why next PR?
Would you remove these if your next PR gets delayed due to something else?
| testConversationWithAppOwnTeam :: (HasCallStack) => ConvType -> App () | ||
| testConversationWithAppOwnTeam ConvTypeProteus = do |
There was a problem hiding this comment.
Why create this ConvType thing and write four different cases for this function, instead of just writing 4 functions?
There was a problem hiding this comment.
short answer it just happened :)
i wrote a comment explaining this, but if that comment isn't compelling i can change it.
| weWant :: User -> Bool | ||
| weWant user = | ||
| not dropBecauseInvitationPending | ||
| && ( isJust user.userIdentity | ||
| || includeUsersWithoutIdentity | ||
| || user.userType == UserTypeApp | ||
| ) | ||
| where | ||
| dropBecauseInvitationPending = | ||
| includePendingInvitations == NoPendingInvitations | ||
| && user.userStatus == PendingInvitation |
There was a problem hiding this comment.
| weWant :: User -> Bool | |
| weWant user = | |
| not dropBecauseInvitationPending | |
| && ( isJust user.userIdentity | |
| || includeUsersWithoutIdentity | |
| || user.userType == UserTypeApp | |
| ) | |
| where | |
| dropBecauseInvitationPending = | |
| includePendingInvitations == NoPendingInvitations | |
| && user.userStatus == PendingInvitation | |
| applyPendingInvitationsFilter :: User -> Bool | |
| applyPendingInvitationsFilter user = | |
| case (includePendingInvitations, user.userStatus) of | |
| (NoPendingInvitations, PendingInvitation) -> False | |
| _ -> True | |
| applyIdentityFilter :: User -> Bool | |
| applyIdentityFilter user = | |
| case (includeUsersWithoutIdentity, user.userType, user.userIdentity) of | |
| (False, UserTypeRegular, Nothing) -> False | |
| _ -> True |
IMO this is easier to understand. Please feel free to change the names of the funtions.
Co-authored-by: Gautier DI FOLCO <gautier.difolco@wire.com>
Co-authored-by: Akshay Mankar <akshay@wire.com>
- s/TODO/FUTUREWORK/ - write 4 test cases, not one with four possible argument values.
…bugging-2' into WPB-22549-events-debugging-2
blackheaven
left a comment
There was a problem hiding this comment.
I have paired on it :)
i think i've handled all your feedback, let me know if i missed anything.
Checklist
changelog.d