Skip to content

Commit f0d0a85

Browse files
committed
Throw not seeded as exception
1 parent 13ba25b commit f0d0a85

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

shared-common/src/Shared/Common/Localization/Messages/Public.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ _ERROR_API_COMMON__UNABLE_TO_GET_TOKEN = LocaleRecord "error.api.common.unable_t
1717

1818
_ERROR_VALIDATION__TENANT_OR_ACTIVE_PLAN_ABSENCE host = LocaleRecord "error.validation.tenant_or_active_plan_absence" "Tenant ('%s') doesn't exist or does not have any active plan" [host]
1919

20+
_ERROR_VALIDATION__NOT_SEEDED_TENANT host = LocaleRecord "error.validation.not_seeded_tenant" "Tenant ('%s') is not seeded" [host]
21+
2022
-- Websocket
2123
_ERROR_API_WEBSOCKET__DESERIALIZATION_FAILED =
2224
LocaleRecord "error.api.websocket.cant_deserialize_obj" "Deserialization failed" []

wizard-server/src/Wizard/Api/Resource/Config/ClientConfigDTO.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import Wizard.Model.Tenant.Config.TenantConfig
88
import Wizard.Model.User.UserProfile
99

1010
data ClientConfigDTO
11-
= NotSeededClientConfigDTO
12-
{ message :: String
13-
}
14-
| HousekeepingInProgressClientConfigDTO
11+
= HousekeepingInProgressClientConfigDTO
1512
{ message :: String
1613
}
1714
| ClientConfigDTO

wizard-server/src/Wizard/Database/DAO/Tenant/TenantDAO.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ findTenantByUuid uuid = createFindEntityByFn entityName [("uuid", U.toString uui
5050
findTenantByServerDomain :: String -> AppContextM Tenant
5151
findTenantByServerDomain serverDomain = createFindEntityByFn entityName [("server_domain", serverDomain)]
5252

53+
findTenantByServerDomain' :: String -> AppContextM (Maybe Tenant)
54+
findTenantByServerDomain' serverDomain = createFindEntityByFn' entityName [("server_domain", serverDomain)]
55+
5356
findTenantByClientUrl :: String -> AppContextM Tenant
5457
findTenantByClientUrl clientUrl = createFindEntityByFn entityName [("client_url", clientUrl)]
5558

wizard-server/src/Wizard/Service/Config/Client/ClientConfigService.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@ getClientConfig mServerUrl mClientUrl = do
3030
if serverConfig.cloud.enabled
3131
then maybe getCurrentTenant findTenantByClientUrl mClientUrl
3232
else getCurrentTenant
33-
unless tenant.enabled (throwError . NotExistsError $ _ERROR_VALIDATION__TENANT_OR_ACTIVE_PLAN_ABSENCE (fromMaybe "not-provided" mServerUrl))
3433
case tenant.state of
3534
NotSeededTenantState -> do
36-
return $ NotSeededClientConfigDTO {message = "We’re currently preparing the instance for you"}
35+
throwError $ UserError (_ERROR_VALIDATION__NOT_SEEDED_TENANT (fromMaybe "not-provided" mServerUrl))
3736
PendingHousekeepingTenantState -> do
37+
throwErrorIfTenantIsDisabled mServerUrl tenant
3838
let mCreatedByUuid = fmap (.uuid) mCurrentUser
3939
migrateToLatestMetamodelVersionCommand tenant mCreatedByUuid
4040
return $ HousekeepingInProgressClientConfigDTO {message = "We’re currently upgrading the data to the latest version to enhance your experience"}
4141
HousekeepingInProgressTenantState -> do
42+
throwErrorIfTenantIsDisabled mServerUrl tenant
4243
return $ HousekeepingInProgressClientConfigDTO {message = "We’re currently upgrading the data to the latest version to enhance your experience"}
4344
ReadyForUseTenantState -> do
45+
throwErrorIfTenantIsDisabled mServerUrl tenant
4446
tenantConfig <-
4547
if serverConfig.cloud.enabled
4648
then case mClientUrl of
@@ -55,3 +57,6 @@ getClientConfig mServerUrl mClientUrl = do
5557
return . Just $ toUserProfile currentUser userGroupUuids
5658
Nothing -> return Nothing
5759
return $ toClientConfigDTO serverConfig tenantConfig mUserProfile tenant locales
60+
61+
throwErrorIfTenantIsDisabled :: Maybe String -> Tenant -> AppContextM ()
62+
throwErrorIfTenantIsDisabled mServerUrl tenant = unless tenant.enabled (throwError . NotExistsError $ _ERROR_VALIDATION__TENANT_OR_ACTIVE_PLAN_ABSENCE (fromMaybe "not-provided" mServerUrl))

0 commit comments

Comments
 (0)