Skip to content

Commit

Permalink
impl db layer
Browse files Browse the repository at this point in the history
  • Loading branch information
battermann committed May 17, 2024
1 parent 325832d commit 37ee52d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
10 changes: 7 additions & 3 deletions services/galley/src/Galley/Cassandra/GetAllTeamFeatureConfigs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ data AllTeamFeatureConfigsRow = AllTeamFeatureConfigsRow
mlsE2eid :: Maybe FeatureStatus,
mlsE2eidGracePeriod :: Maybe Int32,
mlsE2eidAcmeDiscoverUrl :: Maybe HttpsUrl,
mlsE2eidMaybeCrlProxy :: Maybe HttpsUrl,
mlsE2eidMaybeUseProxyOnMobile :: Maybe Bool,
mlsE2eidLock :: Maybe LockStatus,
-- mls migration
mlsMigration :: Maybe FeatureStatus,
Expand Down Expand Up @@ -112,6 +114,8 @@ emptyRow =
mlsE2eid = Nothing,
mlsE2eidGracePeriod = Nothing,
mlsE2eidAcmeDiscoverUrl = Nothing,
mlsE2eidMaybeCrlProxy = Nothing,
mlsE2eidMaybeUseProxyOnMobile = Nothing,
mlsE2eidLock = Nothing,
mlsMigration = Nothing,
mlsMigrationStartTime = Nothing,
Expand Down Expand Up @@ -295,8 +299,8 @@ allFeatureConfigsFromRow ourteam allowListForExposeInvitationURLs featureLH hasT
MlsE2EIdConfig
(toGracePeriodOrDefault row.mlsE2eidGracePeriod)
row.mlsE2eidAcmeDiscoverUrl
(error "TODO:(leif)")
(error "TODO:(leif)")
row.mlsE2eidMaybeCrlProxy
(fromMaybe (useProxyOnMobile . wsConfig $ defFeatureStatus) row.mlsE2eidMaybeUseProxyOnMobile)
where
toGracePeriodOrDefault :: Maybe Int32 -> NominalDiffTime
toGracePeriodOrDefault = maybe (verificationExpiration $ wsConfig defFeatureStatus) fromIntegral
Expand Down Expand Up @@ -370,7 +374,7 @@ getAllFeatureConfigs allowListForExposeInvitationURLs featureLH hasTeamImplicitL
\mls_status, mls_default_protocol, mls_protocol_toggle_users, mls_allowed_ciphersuites, \
\mls_default_ciphersuite, mls_supported_protocols, mls_lock_status, \
\\
\mls_e2eid_status, mls_e2eid_grace_period, mls_e2eid_acme_discovery_url, mls_e2eid_lock_status, \
\mls_e2eid_status, mls_e2eid_grace_period, mls_e2eid_acme_discovery_url, mls_e2eid_crl_proxy, mls_e2eid_use_proxy_on_mobile, mls_e2eid_lock_status, \
\\
\mls_migration_status, mls_migration_start_time, mls_migration_finalise_regardless_after, \
\mls_migration_lock_status, \
Expand Down
19 changes: 10 additions & 9 deletions services/galley/src/Galley/Cassandra/TeamFeatures.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,24 @@ getFeatureConfig FeatureSingletonMlsE2EIdConfig tid = do
let q = query1 select (params LocalQuorum (Identity tid))
retry x1 q <&> \case
Nothing -> Nothing
Just (Nothing, _, _) -> Nothing
Just (Just fs, mGracePeriod, mUrl) ->
Just (Nothing, _, _,_,_) -> Nothing
Just (Just fs, mGracePeriod, mUrl, mCrlProxy, mUseProxyOnMobile) ->
Just $
WithStatusNoLock
fs
( -- FUTUREWORK: this block is duplicated in
-- "Galley.Cassandra.GetAllTeamFeatureConfigs"; make sure the two don't diverge!
-- TODO(leif): implement the missing fields
MlsE2EIdConfig (toGracePeriodOrDefault mGracePeriod) mUrl Nothing False
MlsE2EIdConfig (toGracePeriodOrDefault mGracePeriod) mUrl mCrlProxy (fromMaybe (useProxyOnMobile . wsConfig $ defFeatureStatus @MlsE2EIdConfig) mUseProxyOnMobile)
)
FeatureTTLUnlimited
where
toGracePeriodOrDefault :: Maybe Int32 -> NominalDiffTime
toGracePeriodOrDefault = maybe (verificationExpiration $ wsConfig defFeatureStatus) fromIntegral

select :: PrepQuery R (Identity TeamId) (Maybe FeatureStatus, Maybe Int32, Maybe HttpsUrl)
select :: PrepQuery R (Identity TeamId) (Maybe FeatureStatus, Maybe Int32, Maybe HttpsUrl, Maybe HttpsUrl, Maybe Bool)
select =
fromString $
"select mls_e2eid_status, mls_e2eid_grace_period, mls_e2eid_acme_discovery_url from team_features where team_id = ?"
"select mls_e2eid_status, mls_e2eid_grace_period, mls_e2eid_acme_discovery_url, mls_e2eid_crl_proxy, mls_e2eid_use_proxy_on_mobile from team_features where team_id = ?"
getFeatureConfig FeatureSingletonMlsMigration tid = do
let q = query1 select (params LocalQuorum (Identity tid))
retry x1 q <&> \case
Expand Down Expand Up @@ -293,11 +292,13 @@ setFeatureConfig FeatureSingletonMlsE2EIdConfig tid status = do
let statusValue = wssStatus status
vex = verificationExpiration . wssConfig $ status
mUrl = acmeDiscoveryUrl . wssConfig $ status
retry x5 $ write insert (params LocalQuorum (tid, statusValue, truncate vex, mUrl))
mCrlProxy = crlProxy . wssConfig $ status
useProxy = useProxyOnMobile . wssConfig $ status
retry x5 $ write insert (params LocalQuorum (tid, statusValue, truncate vex, mUrl, mCrlProxy, useProxy))
where
insert :: PrepQuery W (TeamId, FeatureStatus, Int32, Maybe HttpsUrl) ()
insert :: PrepQuery W (TeamId, FeatureStatus, Int32, Maybe HttpsUrl, Maybe HttpsUrl, Bool) ()
insert =
"insert into team_features (team_id, mls_e2eid_status, mls_e2eid_grace_period, mls_e2eid_acme_discovery_url) values (?, ?, ?, ?)"
"insert into team_features (team_id, mls_e2eid_status, mls_e2eid_grace_period, mls_e2eid_acme_discovery_url, mls_e2eid_crl_proxy, mls_e2eid_use_proxy_on_mobile) values (?, ?, ?, ?, ?, ?)"
setFeatureConfig FeatureSingletonMlsMigration tid status = do
let statusValue = wssStatus status
config = wssConfig status
Expand Down

0 comments on commit 37ee52d

Please sign in to comment.