-
Notifications
You must be signed in to change notification settings - Fork 334
WPB-20214: Add member searchability #4786
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: develop
Are you sure you want to change the base?
Conversation
bc31287
to
78ad65e
Compare
The below is now resolved. The current error when running the test is this:
From running this command: |
9891c56
to
6a1a1b8
Compare
6a1a1b8
to
4790b05
Compare
@akshaymankar Noting here what you asked about in the standup: the When we had all data in postgres though, the query could entirely be done on the database side: join |
@eyeinsky I think we shouldn't support this query param on |
4790b05
to
b0f782c
Compare
@akshaymankar I'm ready for another round of review! |
I think we can just lookup the team id of the targetted user and check whether the user who made the request is an admin of that team. We shouldn't need team id in the path.
No, we can expose the fact that his handle is taken as far as we don't tell who has this handle.
Yeah, this is the only location.
Ideally, yes. Sometimes we've been lazy, but the agreed upon rule was to move a test if you need to work on it and not to add more tests in the legacy test suites. |
:<|> Named | ||
"set-user-searchable" | ||
( Summary "Set user's visibility in search" | ||
:> From 'V12 | ||
:> ZLocalUser | ||
:> "users" | ||
:> CaptureUserId "uid" | ||
:> Capture "tid" TeamId | ||
:> ReqBody '[JSON] Bool | ||
:> "searchable" | ||
:> Post '[JSON] () | ||
) |
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.
As mentioned in earlier comment, we shouldn't need the TeamId
in the path.
| SetMemberPermissions | ||
| GetTeamConversations | ||
| DeleteTeam | ||
| SetMemberSearchable |
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.
Shouldn't this go to the HiddenPerm
type?
teamContactEmailUnvalidated = Nothing | ||
teamContactEmailUnvalidated = Nothing, | ||
teamContactSearchable = Nothing |
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.
We should reduce these tests and perhaps add a test where this value is not Nothing
.
teamContactSso :: Maybe Sso, | ||
teamContactEmailUnvalidated :: Maybe EmailAddress | ||
teamContactEmailUnvalidated :: Maybe EmailAddress, | ||
teamContactSearchable :: Maybe Bool |
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 is this a Maybe
?
let domain = Domain "example.com" | ||
let colour = ColourId 0 | ||
let userProfile = UserProfile (Qualified uid domain) (Name "name") Nothing (Pict []) [] colour False Nothing Nothing Nothing Nothing Nothing UserLegalHoldNoConsent defSupportedProtocols UserTypeRegular | ||
let userProfile = UserProfile (Qualified uid domain) (Name "name") Nothing (Pict []) [] colour False Nothing Nothing Nothing Nothing Nothing UserLegalHoldNoConsent defSupportedProtocols UserTypeRegular True |
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'm refactoring these to record syntax whenever I come across them. Its a bit painful, but IMO its necessary to do this as we go.
test p "get /users/<localdomain>/:uid - 404" $ testNonExistingUser b, | ||
test p "get /users/:domain/:uid - 422" $ testUserInvalidDomain b, | ||
test p "get /users/:uid - 200" $ testExistingUserUnqualified b, | ||
test p "testUserSearchable" $ testUserSearchable b g, |
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.
We should write this test in the new test suite.
], | ||
ES.boolQueryShouldMatch = [ES.QueryExistsQuery (ES.FieldName "handle")] | ||
ES.boolQueryShouldMatch = [ES.QueryExistsQuery (ES.FieldName "handle")], | ||
ES.boolQueryMustNotMatch = [ES.TermQuery (ES.Term "searchable" "false") Nothing] |
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.
This looks like it should work with old users who don't have anything set in searchable
, just to be sure did you test it?
If it does work we should write a comment explaining this double negation (mustNot
and false
)
7901c95
to
d791f07
Compare
- make `!!!` definition easier to understand - extract `getProfile`
…=false`" This reverts commit 4790b05.
Co-authored-by: Akshay Mankar <[email protected]>
Co-authored-by: Akshay Mankar <[email protected]>
Make SetMemberSearchable from Perm to HiddenPerm.
99bfb21
to
671e93a
Compare
This reverts commit 68b6c6e.
c0e5357
to
cfc7888
Compare
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.
This needs a release note explaining how the search index mapping has to be updated and how to avoid downtime, etc.
And there are some minor comments, looks good overall.
let -- Helper to change user searchability. | ||
setSearchable self uid searchable = do | ||
req <- baseRequest self Brig Versioned $ joinHttpPath ["users", uid, "searchable"] | ||
submit "POST" $ addJSON searchable req |
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.
this should go into API.Brig
u1' <- BrigP.getUser u1 u1 >>= getJSON 200 | ||
assertBool "Searchable is still True" =<< (u1' %. "searchable" & asBool) |
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.
If u1'
is not used later I would prefer to do the assertion in a bindResponse
body, to reduce number of ticked variable names. Also you could assert like this: u1 %. "searchable"
shouldMatch True
(I think) which I find more readable.
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.
The above applies to the following lines, too.
:> QueryParam' | ||
[ Optional, | ||
Strict, | ||
Description "Optional, return only non-seacrhable members when false." |
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.
will it return only searchable members when true?
randomUserPrefix :: | ||
(MonadCatch m, MonadIO m, MonadHttp m, HasCallStack) => | ||
Text -> | ||
Brig -> | ||
m User | ||
randomUserPrefix prefix brig = do | ||
n <- fromName <$> randomName | ||
createUser' True (prefix <> n) brig | ||
|
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.
this seems unused, no?
Co-authored-by: Leif Battermann <[email protected]>
Task checklist:
searchable
/users/:uid/searchable
API endpoint and by team admin, and nowhere elseSetMemberSearchable
/search/contacts
must filter based on searchable = True/teams/:tid/search
must expose a filter to find non-searchable users; otherwise ignore itsearchable
field behaviorOpen questions
POST /users/:uid/searchable
, but as TeamId is required, then it currently isPOST /users/:uid/:tid/searchable
-- could this be improved?POST /handles
: should this endpoint also filter based on searchability?/search/contacts
to take searchability into account?Checklist
changelog.d