mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-04 20:28:00 +00:00
chore: tweak workspace setting definition
This commit is contained in:
@ -12,36 +12,26 @@ func (s *Store) MigrateWorkspaceSettings(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
workspaceSettingGeneral, err := s.GetWorkspaceSetting(ctx, &FindWorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL,
|
||||
})
|
||||
workspaceGeneralSetting, err := s.GetWorkspaceGeneralSetting(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if workspaceSettingGeneral == nil || workspaceSettingGeneral.GetGeneral() == nil {
|
||||
workspaceSettingGeneral = &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL,
|
||||
Value: &storepb.WorkspaceSetting_General{
|
||||
General: &storepb.WorkspaceSetting_GeneralSetting{},
|
||||
},
|
||||
}
|
||||
}
|
||||
updateWorkspaceSetting := false
|
||||
for _, workspaceSetting := range workspaceSettings {
|
||||
if workspaceSetting.Key == storepb.WorkspaceSettingKey_WORKSPACE_SETTING_LICENSE_KEY {
|
||||
workspaceSettingGeneral.GetGeneral().LicenseKey = workspaceSetting.Raw
|
||||
workspaceGeneralSetting.LicenseKey = workspaceSetting.Raw
|
||||
updateWorkspaceSetting = true
|
||||
if err := s.DeleteWorkspaceSetting(ctx, storepb.WorkspaceSettingKey_WORKSPACE_SETTING_LICENSE_KEY); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if workspaceSetting.Key == storepb.WorkspaceSettingKey_WORKSPACE_SETTING_CUSTOM_STYLE {
|
||||
workspaceSettingGeneral.GetGeneral().CustomStyle = workspaceSetting.Raw
|
||||
workspaceGeneralSetting.CustomStyle = workspaceSetting.Raw
|
||||
updateWorkspaceSetting = true
|
||||
if err := s.DeleteWorkspaceSetting(ctx, storepb.WorkspaceSettingKey_WORKSPACE_SETTING_CUSTOM_STYLE); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if workspaceSetting.Key == storepb.WorkspaceSettingKey_WORKSPACE_SETTING_SECRET_SESSION {
|
||||
workspaceSettingGeneral.GetGeneral().SecretSession = workspaceSetting.Raw
|
||||
workspaceGeneralSetting.SecretSession = workspaceSetting.Raw
|
||||
updateWorkspaceSetting = true
|
||||
if err := s.DeleteWorkspaceSetting(ctx, storepb.WorkspaceSettingKey_WORKSPACE_SETTING_SECRET_SESSION); err != nil {
|
||||
return err
|
||||
@ -49,7 +39,12 @@ func (s *Store) MigrateWorkspaceSettings(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
if updateWorkspaceSetting {
|
||||
if _, err := s.UpsertWorkspaceSetting(ctx, workspaceSettingGeneral); err != nil {
|
||||
if _, err := s.UpsertWorkspaceSetting(ctx, &storepb.WorkspaceSetting{
|
||||
Key: storepb.WorkspaceSettingKey_WORKSPACE_SETTING_GENERAL,
|
||||
Value: &storepb.WorkspaceSetting_General{
|
||||
General: workspaceGeneralSetting,
|
||||
},
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user