Skip to content

Commit

Permalink
WPB-14856 fix: Personal user to team owner not listed in team search (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
battermann authored Dec 5, 2024
1 parent d819885 commit a16b1f2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/3-bug-fixes/WPB-14856
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed search index after personal user creates team
6 changes: 6 additions & 0 deletions integration/test/API/Brig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ searchTeam user q = do
req <- baseRequest user Brig Versioned $ joinHttpPath ["teams", tid, "search"]
submit "GET" (req & addQueryParams [("q", q)])

searchTeamAll :: (HasCallStack, MakesValue user) => user -> App Response
searchTeamAll user = do
tid <- user %. "team" & asString
req <- baseRequest user Brig Versioned $ joinHttpPath ["teams", tid, "search"]
submit "GET" (req & addQueryParams [("q", ""), ("size", "100"), ("sortby", "created_at"), ("sortorder", "desc")])

getAPIVersion :: (HasCallStack, MakesValue domain) => domain -> App Response
getAPIVersion domain = do
req <- baseRequest domain Brig Unversioned $ "/api-version"
Expand Down
10 changes: 10 additions & 0 deletions integration/test/Test/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,16 @@ testUpgradePersonalToTeam = do
shouldBeNull $ owner %. "created_at"
shouldBeNull $ owner %. "created_by"

mem <- createTeamMember alice' def
I.refreshIndex OwnDomain

bindResponse (searchTeamAll alice') $ \resp -> do
resp.status `shouldMatchInt` 200
docs <- resp.json %. "documents" >>= asList
actualIds <- for docs ((%. "id") >=> asString)
expectedIds <- for [alice', mem] ((%. "id") >=> asString)
actualIds `shouldMatchSet` expectedIds

testUpgradePersonalToTeamAlreadyInATeam :: (HasCallStack) => App ()
testUpgradePersonalToTeamAlreadyInATeam = do
(alice, _, _) <- createTeam OwnDomain 0
Expand Down
1 change: 1 addition & 0 deletions services/brig/src/Brig/API/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ upgradePersonalToTeam luid bNewTeam = do
pure $ CreateUserTeam tid (fromRange newTeam.newTeamName)

liftSem $ updateUserTeam uid tid
liftSem $ User.internalUpdateSearchIndex uid
liftSem $ Intra.sendUserEvent uid Nothing (teamUpdated uid tid)
initAccountFeatureConfig uid

Expand Down

0 comments on commit a16b1f2

Please sign in to comment.