From a16b1f2c7512a79bda1b79bceabfec15306b6b2c Mon Sep 17 00:00:00 2001 From: Leif Battermann Date: Thu, 5 Dec 2024 15:29:01 +0100 Subject: [PATCH] WPB-14856 fix: Personal user to team owner not listed in team search (#4362) --- changelog.d/3-bug-fixes/WPB-14856 | 1 + integration/test/API/Brig.hs | 6 ++++++ integration/test/Test/Teams.hs | 10 ++++++++++ services/brig/src/Brig/API/User.hs | 1 + 4 files changed, 18 insertions(+) create mode 100644 changelog.d/3-bug-fixes/WPB-14856 diff --git a/changelog.d/3-bug-fixes/WPB-14856 b/changelog.d/3-bug-fixes/WPB-14856 new file mode 100644 index 00000000000..dac6620ceb2 --- /dev/null +++ b/changelog.d/3-bug-fixes/WPB-14856 @@ -0,0 +1 @@ +Fixed search index after personal user creates team diff --git a/integration/test/API/Brig.hs b/integration/test/API/Brig.hs index 5cd0e2053ba..b788d3c6f74 100644 --- a/integration/test/API/Brig.hs +++ b/integration/test/API/Brig.hs @@ -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" diff --git a/integration/test/Test/Teams.hs b/integration/test/Test/Teams.hs index aeca67789f1..2d566527c0e 100644 --- a/integration/test/Test/Teams.hs +++ b/integration/test/Test/Teams.hs @@ -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 diff --git a/services/brig/src/Brig/API/User.hs b/services/brig/src/Brig/API/User.hs index 513a1075723..92d260f6d2f 100644 --- a/services/brig/src/Brig/API/User.hs +++ b/services/brig/src/Brig/API/User.hs @@ -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