Skip to content

Commit

Permalink
Fixup 9132bee
Browse files Browse the repository at this point in the history
  • Loading branch information
fisx committed Jan 2, 2024
1 parent a8102f4 commit d7100f3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
15 changes: 9 additions & 6 deletions libs/wire-api/src/Wire/API/Team/Feature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ import Wire.Arbitrary (Arbitrary, GenericUniform (..))
-- (https://github.com/wireapp/wire-server/pull/1811,
-- https://github.com/wireapp/wire-server/pull/1818)
--
-- 10. Extend the integration tests with cases
-- 10. Extend the integration tests with cases.
--
-- 11. Edit/update the configurations:
-- 11. If applicable, edit/update the configurations:
-- - optionally add the config for local integration tests to 'galley.integration.yaml'
-- - add a config mapping to 'charts/galley/templates/configmap.yaml'
-- - add the defaults to 'charts/galley/values.yaml'
-- - optionally add config for CI to 'hack/helm_vars/wire-server/values.yaml'
--
-- 12. Add a section to the documentation at an appropriate place
-- (e.g. 'docs/src/developer/reference/config-options.md' or
-- (e.g. 'docs/src/developer/reference/config-options.md' (if applicable) or
-- 'docs/src/understand/team-feature-settings.md')
class IsFeatureConfig cfg where
type FeatureSymbol cfg :: Symbol
Expand Down Expand Up @@ -206,8 +206,11 @@ data FeatureSingleton cfg where
FeatureSingletonExposeInvitationURLsToTeamAdminConfig :: FeatureSingleton ExposeInvitationURLsToTeamAdminConfig
FeatureSingletonOutlookCalIntegrationConfig :: FeatureSingleton OutlookCalIntegrationConfig
FeatureSingletonMlsE2EIdConfig :: FeatureSingleton MlsE2EIdConfig
FeatureSingletonMlsMigration :: FeatureSingleton MlsMigrationConfig
FeatureSingletonEnforceFileDownloadLocation :: FeatureSingleton EnforceFileDownloadLocationConfig
FeatureSingletonMlsMigration ::
-- FUTUREWORK: rename to `FeatureSingletonMlsMigrationConfig` (or drop the `Config` from
-- all other constructors)
FeatureSingleton MlsMigrationConfig
FeatureSingletonEnforceFileDownloadLocationConfig :: FeatureSingleton EnforceFileDownloadLocationConfig

class FeatureTrivialConfig cfg where
trivialConfig :: cfg
Expand Down Expand Up @@ -1112,7 +1115,7 @@ instance ToSchema EnforceFileDownloadLocationConfig where
instance IsFeatureConfig EnforceFileDownloadLocationConfig where
type FeatureSymbol EnforceFileDownloadLocationConfig = "enforceFileDownloadLocation"
defFeatureStatus = withStatus FeatureStatusDisabled LockStatusLocked (EnforceFileDownloadLocationConfig Nothing) FeatureTTLUnlimited
featureSingleton = FeatureSingletonEnforceFileDownloadLocation
featureSingleton = FeatureSingletonEnforceFileDownloadLocationConfig
objectSchema = field "config" schema

----------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions services/galley/src/Galley/Cassandra/TeamFeatures.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ getFeatureConfig FeatureSingletonMlsMigration tid = do
select = "select mls_migration_status, mls_migration_start_time, mls_migration_finalise_regardless_after from team_features where team_id = ?"
getFeatureConfig FeatureSingletonExposeInvitationURLsToTeamAdminConfig tid = getTrivialConfigC "expose_invitation_urls_to_team_admin" tid
getFeatureConfig FeatureSingletonOutlookCalIntegrationConfig tid = getTrivialConfigC "outlook_cal_integration_status" tid
getFeatureConfig FeatureSingletonEnforceFileDownloadLocation tid = do
getFeatureConfig FeatureSingletonEnforceFileDownloadLocationConfig tid = do
let q = query1 select (params LocalQuorum (Identity tid))
retry x1 q <&> \case
Nothing -> Nothing
Expand Down Expand Up @@ -256,7 +256,7 @@ setFeatureConfig FeatureSingletonMlsMigration tid status = do
"insert into team_features (team_id, mls_migration_status, mls_migration_start_time, mls_migration_finalise_regardless_after) values (?, ?, ?, ?)"
setFeatureConfig FeatureSingletonExposeInvitationURLsToTeamAdminConfig tid statusNoLock = setFeatureStatusC "expose_invitation_urls_to_team_admin" tid (wssStatus statusNoLock)
setFeatureConfig FeatureSingletonOutlookCalIntegrationConfig tid statusNoLock = setFeatureStatusC "outlook_cal_integration_status" tid (wssStatus statusNoLock)
setFeatureConfig FeatureSingletonEnforceFileDownloadLocation tid status = do
setFeatureConfig FeatureSingletonEnforceFileDownloadLocationConfig tid status = do
let statusValue = wssStatus status
config = wssConfig status

Expand All @@ -275,7 +275,7 @@ getFeatureLockStatus FeatureSingletonMlsE2EIdConfig tid = getLockStatusC "mls_e2
getFeatureLockStatus FeatureSingletonMlsMigration tid = getLockStatusC "mls_migration_lock_status" tid
getFeatureLockStatus FeatureSingletonOutlookCalIntegrationConfig tid = getLockStatusC "outlook_cal_integration_lock_status" tid
getFeatureLockStatus FeatureSingletonMLSConfig tid = getLockStatusC "mls_lock_status" tid
getFeatureLockStatus FeatureSingletonEnforceFileDownloadLocation tid = getLockStatusC "enforce_file_download_location_lock_status" tid
getFeatureLockStatus FeatureSingletonEnforceFileDownloadLocationConfig tid = getLockStatusC "enforce_file_download_location_lock_status" tid
getFeatureLockStatus _ _ = pure Nothing

setFeatureLockStatus :: MonadClient m => FeatureSingleton cfg -> TeamId -> LockStatus -> m ()
Expand All @@ -287,7 +287,7 @@ setFeatureLockStatus FeatureSingletonMlsE2EIdConfig tid status = setLockStatusC
setFeatureLockStatus FeatureSingletonMlsMigration tid status = setLockStatusC "mls_migration_lock_status" tid status
setFeatureLockStatus FeatureSingletonOutlookCalIntegrationConfig tid status = setLockStatusC "outlook_cal_integration_lock_status" tid status
setFeatureLockStatus FeatureSingletonMLSConfig tid status = setLockStatusC "mls_lock_status" tid status
setFeatureLockStatus FeatureSingletonEnforceFileDownloadLocation tid status = setLockStatusC "enforce_file_download_location_lock_status" tid status
setFeatureLockStatus FeatureSingletonEnforceFileDownloadLocationConfig tid status = setLockStatusC "enforce_file_download_location_lock_status" tid status
setFeatureLockStatus _ _tid _status = pure ()

getTrivialConfigC ::
Expand Down
4 changes: 3 additions & 1 deletion services/galley/src/Galley/Schema/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import Galley.Schema.V86_TeamFeatureMlsMigration qualified as V86_TeamFeatureMls
import Galley.Schema.V87_TeamFeatureSupportedProtocols qualified as V87_TeamFeatureSupportedProtocols
import Galley.Schema.V88_RemoveMemberClientAndTruncateMLSGroupMemberClient qualified as V88_RemoveMemberClientAndTruncateMLSGroupMemberClient
import Galley.Schema.V89_MlsLockStatus qualified as V89_MlsLockStatus
import Galley.Schema.V90_EnforceFileDownloadLocationConfig qualified as V90_EnforceFileDownloadLocationConfig
import Imports
import Options.Applicative
import System.Logger.Extended qualified as Log
Expand Down Expand Up @@ -180,7 +181,8 @@ migrations =
V86_TeamFeatureMlsMigration.migration,
V87_TeamFeatureSupportedProtocols.migration,
V88_RemoveMemberClientAndTruncateMLSGroupMemberClient.migration,
V89_MlsLockStatus.migration
V89_MlsLockStatus.migration,
V90_EnforceFileDownloadLocationConfig.migration
-- FUTUREWORK: once #1726 has made its way to master/production,
-- the 'message' field in connections table can be dropped.
-- See also https://github.com/wireapp/wire-server/pull/1747/files
Expand Down
7 changes: 6 additions & 1 deletion services/galley/test/integration/API/Teams/Feature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ tests s =
),
test s "MlsMigration feature config" $
testNonTrivialConfigNoTTL defaultMlsMigrationConfig,
test s "EnforceFileDownloadLocation feature config" $
testNonTrivialConfigNoTTL (defFeatureStatus @EnforceFileDownloadLocationConfig),
testGroup
"Patch"
[ -- Note: `SSOConfig` and `LegalHoldConfig` may not be able to be reset
Expand Down Expand Up @@ -150,7 +152,10 @@ tests s =
testPatch AssertLockStatusChange FeatureStatusEnabled (SelfDeletingMessagesConfig 0),
test s (unpack $ featureNameBS @OutlookCalIntegrationConfig) $
testPatch AssertLockStatusChange FeatureStatusDisabled OutlookCalIntegrationConfig,
test s (unpack $ featureNameBS @MlsE2EIdConfig) $ testPatchWithArbitrary AssertLockStatusChange FeatureStatusDisabled (wsConfig (defFeatureStatus @MlsE2EIdConfig))
test s (unpack $ featureNameBS @MlsE2EIdConfig) $
testPatchWithArbitrary AssertLockStatusChange FeatureStatusDisabled (wsConfig (defFeatureStatus @MlsE2EIdConfig)),
test s (unpack $ featureNameBS @EnforceFileDownloadLocationConfig) $
testPatchWithArbitrary AssertLockStatusChange FeatureStatusDisabled (wsConfig (defFeatureStatus @EnforceFileDownloadLocationConfig))
],
testGroup
"ExposeInvitationURLsToTeamAdmin"
Expand Down

0 comments on commit d7100f3

Please sign in to comment.