From b459bd35583d216625a72cb9f71dbae6977a7982 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Fri, 16 Jul 2021 13:19:08 +0200 Subject: [PATCH] Remove obsolete settings (ns switcher, one) --- .../migrations_202109_settings_cleanup.go | 35 ++++++++++++++ pkg/provision/provision.go | 1 + provision/001_settings/compose.yaml | 1 - system/types/app_settings.go | 48 ++----------------- 4 files changed, 39 insertions(+), 46 deletions(-) create mode 100644 pkg/provision/migrations_202109_settings_cleanup.go diff --git a/pkg/provision/migrations_202109_settings_cleanup.go b/pkg/provision/migrations_202109_settings_cleanup.go new file mode 100644 index 000000000..9b1cc980f --- /dev/null +++ b/pkg/provision/migrations_202109_settings_cleanup.go @@ -0,0 +1,35 @@ +package provision + +import ( + "context" + + "github.com/cortezaproject/corteza-server/store" + "go.uber.org/zap" +) + +func cleanupPre202109Settings(ctx context.Context, log *zap.Logger, s store.Storer) (err error) { + log.Info("cleaning up pre-2021.9 settings") + names := []string{ + "compose.ui.namespace-switcher.enabled", + "compose.ui.namespace-switcher.default-open", + "messaging.message.attachments.enabled", + "messaging.message.attachments.max-size", + "messaging.message.attachments.mimetypes", + "messaging.message.attachments.source.camera.enabled", + "messaging.message.attachments.source.gallery.enabled", + "messaging.ui.browser-notifications.enabled", + "messaging.ui.browser-notifications.header", + "messaging.ui.browser-notifications.message-trim", + "messaging.ui.emoji.enabled", + "auth.external.session-store-secret", + "auth.external.session-store-secure", + } + + for _, name := range names { + if err = store.DeleteSettingByNameOwnedBy(ctx, s, name, 0); err != nil { + return + } + } + + return +} diff --git a/pkg/provision/provision.go b/pkg/provision/provision.go index b634f3f35..9982fde0e 100644 --- a/pkg/provision/provision.go +++ b/pkg/provision/provision.go @@ -30,6 +30,7 @@ func Run(ctx context.Context, log *zap.Logger, s store.Storer, provisionOpt opti func() error { return migrateEmailTemplates(ctx, log.Named("email-templates"), s) }, func() error { return migratePre202106Roles(ctx, log.Named("pre-202106-roles"), s) }, func() error { return migratePre202106RbacRules(ctx, log.Named("pre-202106-rbac-rules"), s) }, + func() error { return cleanupPre202109Settings(ctx, log.Named("pre-202106-rbac-rules"), s) }, // Config (full & partial) func() error { return importConfig(ctx, log.Named("config"), s, provisionOpt.Path) }, diff --git a/provision/001_settings/compose.yaml b/provision/001_settings/compose.yaml index 576ab02f9..1a6914270 100644 --- a/provision/001_settings/compose.yaml +++ b/provision/001_settings/compose.yaml @@ -1,5 +1,4 @@ settings: - compose.ui.namespace-switcher.enabled: false compose.record.attachments.max-size: 10 compose.record.attachments.mimetypes: [] diff --git a/system/types/app_settings.go b/system/types/app_settings.go index 4391d1cab..0ce5894e7 100644 --- a/system/types/app_settings.go +++ b/system/types/app_settings.go @@ -109,57 +109,15 @@ type ( Mail struct { FromAddress string `kv:"from-address"` FromName string `kv:"from-name"` - - EmailConfirmation struct { - Subject string `kv:"subject.en"` - Body string `kv:"body.en"` - } `kv:"email-confirmation"` - - PasswordReset struct { - Subject string `kv:"subject.en"` - Body string `kv:"body.en"` - } `kv:"password-reset"` } `json:"-"` } `json:"-"` - UI struct { - // Corteza One configuration settings - One struct { - Logo string `kv:"logo" json:"logo"` - Title string `kv:"title" json:"title"` - - PanelsEnabled bool `kv:"panels-enabled" json:"panelsEnabled"` - Panels []struct { - Visible bool `json:"visible"` - Sticky bool `json:"sticky"` - Width uint `json:"width"` - Height uint `json:"height"` - ActiveTabIndex uint `json:"activeTabIndex"` - Tabs []struct { - Title string `json:"title"` - Url string `json:"url"` - Logo string `json:"logo"` - Icon string `json:"icon"` - Sticky bool `json:"sticky"` - } `json:"tabs"` - } `kv:"panels,final" json:"panels"` - } `kv:"one" json:"one"` - - // Admin struct {} `kv:"admin"` - } `kv:"ui" json:"ui"` - Compose struct { // UI related settings - UI struct { - // Emoji - // @todo implementation - NamespaceSwitcher struct { - Enabled bool - DefaultOpen bool - } `kv:"namespace-switcher"` - } `kv:"ui"` + // (placeholder) + UI struct{} `kv:"ui"` - // Message related settings + // Record related settings Record struct { // @todo implementation Attachments struct {