-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify team feature database interface; add validate-saml-emails fe…
…ature to stern/backoffice (#1129) * Simplify team feature database interface. There was one Data.* module per column in the team_features table. That may make sense at some point in the distant future, but as long as all those columns are just booleans, having one haskell module to access any of them in a uniform way saves a lot of boilerplate. * Use new feature flag types and make a generic end-point in stern. * Add FUTUREWORKs. Co-authored-by: Akshay Mankar <akshay@wire.com>
- Loading branch information
1 parent
ce3bb4f
commit 869c7ac
Showing
15 changed files
with
121 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{-# LANGUAGE ViewPatterns #-} | ||
|
||
-- This file is part of the Wire Server implementation. | ||
-- | ||
-- Copyright (C) 2020 Wire Swiss GmbH <opensource@wire.com> | ||
-- | ||
-- This program is free software: you can redistribute it and/or modify it under | ||
-- the terms of the GNU Affero General Public License as published by the Free | ||
-- Software Foundation, either version 3 of the License, or (at your option) any | ||
-- later version. | ||
-- | ||
-- This program is distributed in the hope that it will be useful, but WITHOUT | ||
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
-- details. | ||
-- | ||
-- You should have received a copy of the GNU Affero General Public License along | ||
-- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
module Galley.Data.TeamFeatures | ||
( setFlag, | ||
getFlag, | ||
) | ||
where | ||
|
||
import Cassandra | ||
import Data.Id | ||
import Galley.Data.Instances () | ||
import Imports | ||
import Wire.API.Team.Feature (TeamFeatureName (..), TeamFeatureStatus (..)) | ||
|
||
-- | Is a given feature enabled or disabled? Returns 'Nothing' if team does not exist or the | ||
-- feature flag in Cassandra is null. | ||
getFlag :: MonadClient m => TeamId -> TeamFeatureName -> m (Maybe TeamFeatureStatus) | ||
getFlag tid feature = (>>= runIdentity) <$> retry x1 (query1 (select feature) (params Quorum (Identity tid))) | ||
|
||
-- | Enable or disable feature flag. | ||
setFlag :: MonadClient m => TeamId -> TeamFeatureName -> TeamFeatureStatus -> m () | ||
setFlag tid feature flag = do retry x5 $ write (update feature) (params Quorum (flag, tid)) | ||
|
||
select :: TeamFeatureName -> PrepQuery R (Identity TeamId) (Identity (Maybe TeamFeatureStatus)) | ||
select feature = fromString $ "select " <> toCol feature <> " from team_features where team_id = ?" | ||
|
||
update :: TeamFeatureName -> PrepQuery W (TeamFeatureStatus, TeamId) () | ||
update feature = fromString $ "update team_features set " <> toCol feature <> " = ? where team_id = ?" | ||
|
||
toCol :: TeamFeatureName -> String | ||
toCol TeamFeatureLegalHold = "legalhold_status" | ||
toCol TeamFeatureSSO = "sso_status" | ||
toCol TeamFeatureSearchVisibility = "search_visibility_status" | ||
toCol TeamFeatureValidateSAMLEmails = "validate_saml_emails" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.