Skip to content

Commit

Permalink
galley: Delete unused endpoint for getting feature status for multipl…
Browse files Browse the repository at this point in the history
…e teams (#4326)
  • Loading branch information
akshaymankar authored Nov 4, 2024
1 parent ce9d00a commit c804cb5
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 116 deletions.
1 change: 1 addition & 0 deletions changelog.d/5-internal/delete-multi-get
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
galley: Delete unused endpoint for getting feature status for multiple teams
14 changes: 0 additions & 14 deletions integration/test/Test/FeatureFlags/SearchVisibilityInbound.hs
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
module Test.FeatureFlags.SearchVisibilityInbound where

import qualified API.Galley as Public
import qualified API.GalleyInternal as Internal
import SetupHelpers
import Test.FeatureFlags.Util
import Testlib.Prelude

testFeatureNoConfigMultiSearchVisibilityInbound :: (HasCallStack) => App ()
testFeatureNoConfigMultiSearchVisibilityInbound = do
(_owner1, team1, _) <- createTeam OwnDomain 0
(_owner2, team2, _) <- createTeam OwnDomain 0

assertSuccess =<< Internal.setTeamFeatureStatus OwnDomain team2 "searchVisibilityInbound" "enabled"

response <- Internal.getFeatureStatusMulti OwnDomain "searchVisibilityInbound" [team1, team2]

statuses <- response.json %. "default_status" >>= asList
length statuses `shouldMatchInt` 2
statuses `shouldMatchSet` [object ["team" .= team1, "status" .= "disabled"], object ["team" .= team2, "status" .= "enabled"]]

testSearchVisibilityInboundInternal :: (HasCallStack) => APIAccess -> App ()
testSearchVisibilityInboundInternal access = do
let featureName = "searchVisibilityInbound"
Expand Down
16 changes: 0 additions & 16 deletions libs/wire-api/src/Wire/API/Routes/Internal/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import Wire.API.Provider.Service (ServiceRef)
import Wire.API.Routes.Features
import Wire.API.Routes.Internal.Brig.EJPD
import Wire.API.Routes.Internal.Galley.ConversationsIntra
import Wire.API.Routes.Internal.Galley.TeamFeatureNoConfigMulti
import Wire.API.Routes.Internal.Galley.TeamsIntra
import Wire.API.Routes.MultiVerb
import Wire.API.Routes.Named
Expand Down Expand Up @@ -82,8 +81,6 @@ type IFeatureAPI =
:<|> IFeatureStatusLockStatusPut MlsE2EIdConfig
:<|> IFeatureStatusLockStatusPut MlsMigrationConfig
:<|> IFeatureStatusLockStatusPut EnforceFileDownloadLocationConfig
-- special endpoints
:<|> IFeatureNoConfigMultiGet SearchVisibilityInboundConfig
-- all feature configs
:<|> Named
"feature-configs-internal"
Expand Down Expand Up @@ -359,19 +356,6 @@ type IFeatureStatusLockStatusPut cfg =
:> Put '[JSON] LockStatusResponse
)

type FeatureNoConfigMultiGetBase featureName =
Summary
(AppendSymbol "Get team feature status in bulk for feature " (FeatureSymbol featureName))
:> "features-multi-teams"
:> FeatureSymbol featureName
:> ReqBody '[JSON] TeamFeatureNoConfigMultiRequest
:> Post '[JSON] (TeamFeatureNoConfigMultiResponse featureName)

type IFeatureNoConfigMultiGet f =
Named
'("igetmulti", f)
(FeatureNoConfigMultiGetBase f)

type IFederationAPI =
Named
"get-federation-status"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Wire.API.Routes.Internal.Galley.TeamFeatureNoConfigMulti
( TeamFeatureNoConfigMultiRequest (..),
TeamFeatureNoConfigMultiResponse (..),
TeamStatus (..),
( TeamStatus (..),
)
where

Expand All @@ -29,30 +27,6 @@ import Data.Schema
import Imports
import Wire.API.Team.Feature qualified as Public

newtype TeamFeatureNoConfigMultiRequest = TeamFeatureNoConfigMultiRequest
{ teams :: [TeamId]
}
deriving (Show, Eq)
deriving (A.ToJSON, A.FromJSON, S.ToSchema) via Schema TeamFeatureNoConfigMultiRequest

instance ToSchema TeamFeatureNoConfigMultiRequest where
schema =
object "TeamFeatureNoConfigMultiRequest" $
TeamFeatureNoConfigMultiRequest
<$> teams .= field "teams" (array schema)

newtype TeamFeatureNoConfigMultiResponse cfg = TeamFeatureNoConfigMultiResponse
{ teamsStatuses :: [TeamStatus cfg]
}
deriving (Show, Eq)
deriving (A.ToJSON, A.FromJSON, S.ToSchema) via Schema (TeamFeatureNoConfigMultiResponse cfg)

instance ToSchema (TeamFeatureNoConfigMultiResponse cfg) where
schema =
object "TeamFeatureNoConfigMultiResponse" $
TeamFeatureNoConfigMultiResponse
<$> teamsStatuses .= field "default_status" (array schema)

data TeamStatus cfg = TeamStatus
{ team :: TeamId,
status :: Public.FeatureStatus
Expand Down
2 changes: 0 additions & 2 deletions services/galley/src/Galley/API/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ featureAPI =
<@> mkNamedAPI @'("ilock", MlsE2EIdConfig) (updateLockStatus @MlsE2EIdConfig)
<@> mkNamedAPI @'("ilock", MlsMigrationConfig) (updateLockStatus @MlsMigrationConfig)
<@> mkNamedAPI @'("ilock", EnforceFileDownloadLocationConfig) (updateLockStatus @EnforceFileDownloadLocationConfig)
-- special endpoints
<@> mkNamedAPI @'("igetmulti", SearchVisibilityInboundConfig) getFeatureMulti
-- all features
<@> mkNamedAPI @"feature-configs-internal" (maybe getAllTeamFeaturesForServer getAllTeamFeaturesForUser)

Expand Down
3 changes: 1 addition & 2 deletions services/galley/src/Galley/API/Teams/Features.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Galley.API.Teams.Features
( getFeatureMulti,
setFeature,
( setFeature,
setFeatureInternal,
patchFeatureInternal,
getAllTeamFeaturesForTeam,
Expand Down
31 changes: 0 additions & 31 deletions services/galley/src/Galley/API/Teams/Features/Get.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
module Galley.API.Teams.Features.Get
( getFeature,
getFeatureInternal,
getFeatureMulti,
getAllTeamFeaturesForServer,
getAllTeamFeaturesForTeam,
getAllTeamFeaturesForUser,
Expand Down Expand Up @@ -142,20 +141,6 @@ getFeatureInternal tid = do
assertTeamExists tid
getFeatureForTeam tid

getFeatureMulti ::
forall cfg r.
( GetFeatureConfig cfg,
ComputeFeatureConstraints cfg r,
Member (Input Opts) r,
Member TeamFeatureStore r
) =>
Multi.TeamFeatureNoConfigMultiRequest ->
Sem r (Multi.TeamFeatureNoConfigMultiResponse cfg)
getFeatureMulti (Multi.TeamFeatureNoConfigMultiRequest tids) = do
cfgs <- getFeatureForMultiTeam @cfg tids
let xs = uncurry toTeamStatus <$> cfgs
pure $ Multi.TeamFeatureNoConfigMultiResponse xs

toTeamStatus :: TeamId -> LockableFeature cfg -> Multi.TeamStatus cfg
toTeamStatus tid feat = Multi.TeamStatus tid feat.status

Expand Down Expand Up @@ -284,22 +269,6 @@ getFeatureForTeam tid = do
defFeature
dbFeature

getFeatureForMultiTeam ::
forall cfg r.
( GetFeatureConfig cfg,
ComputeFeatureConstraints cfg r,
Member TeamFeatureStore r,
Member (Input Opts) r
) =>
[TeamId] ->
Sem r [(TeamId, LockableFeature cfg)]
getFeatureForMultiTeam tids = do
defFeature <- getFeatureForServer
features <- getDbFeatureMulti tids
for features $ \(tid, dbFeature) -> do
feat <- computeFeature @cfg tid defFeature dbFeature
pure (tid, feat)

getFeatureForTeamUser ::
forall cfg r.
( GetFeatureConfig cfg,
Expand Down
14 changes: 0 additions & 14 deletions services/galley/src/Galley/Cassandra/TeamFeatures.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

module Galley.Cassandra.TeamFeatures
( interpretTeamFeatureStoreToCassandra,
getDbFeatureMulti,
getAllTeamFeaturesForServer,
)
where
Expand All @@ -38,7 +37,6 @@ import Imports
import Polysemy
import Polysemy.Input
import Polysemy.TinyLog
import UnliftIO.Async (pooledMapConcurrentlyN)
import Wire.API.Team.Feature

interpretTeamFeatureStoreToCassandra ::
Expand All @@ -52,9 +50,6 @@ interpretTeamFeatureStoreToCassandra = interpret $ \case
TFS.GetDbFeature sing tid -> do
logEffect "TeamFeatureStore.GetFeatureConfig"
embedClient $ getDbFeature sing tid
TFS.GetDbFeatureMulti sing tids -> do
logEffect "TeamFeatureStore.GetFeatureConfigMulti"
embedClient $ getDbFeatureMulti sing tids
TFS.SetDbFeature sing tid feat -> do
logEffect "TeamFeatureStore.SetFeatureConfig"
embedClient $ setDbFeature sing tid feat
Expand All @@ -65,15 +60,6 @@ interpretTeamFeatureStoreToCassandra = interpret $ \case
logEffect "TeamFeatureStore.GetAllTeamFeatures"
embedClient $ getAllDbFeatures tid

getDbFeatureMulti ::
forall cfg m.
(MonadClient m, MonadUnliftIO m) =>
FeatureSingleton cfg ->
[TeamId] ->
m [(TeamId, DbFeature cfg)]
getDbFeatureMulti proxy =
pooledMapConcurrentlyN 8 (\tid -> getDbFeature proxy tid <&> (tid,))

getDbFeature :: (MonadClient m) => FeatureSingleton cfg -> TeamId -> m (DbFeature cfg)
getDbFeature = $(featureCases [|fetchFeature|])

Expand Down
10 changes: 0 additions & 10 deletions services/galley/src/Galley/Effects/TeamFeatureStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ data TeamFeatureStore m a where
FeatureSingleton cfg ->
TeamId ->
TeamFeatureStore m (DbFeature cfg)
GetDbFeatureMulti ::
FeatureSingleton cfg ->
[TeamId] ->
TeamFeatureStore m [(TeamId, DbFeature cfg)]
SetDbFeature ::
FeatureSingleton cfg ->
TeamId ->
Expand All @@ -51,12 +47,6 @@ getDbFeature ::
Sem r (DbFeature cfg)
getDbFeature tid = send (GetDbFeature featureSingleton tid)

getDbFeatureMulti ::
(Member TeamFeatureStore r, IsFeatureConfig cfg) =>
[TeamId] ->
Sem r [(TeamId, DbFeature cfg)]
getDbFeatureMulti tids = send (GetDbFeatureMulti featureSingleton tids)

setDbFeature ::
(Member TeamFeatureStore r, IsFeatureConfig cfg) =>
TeamId ->
Expand Down

0 comments on commit c804cb5

Please sign in to comment.