summaryrefslogtreecommitdiffstats
path: root/app/import_functions.go
diff options
context:
space:
mode:
authorFurmanovD <39990503+FurmanovD@users.noreply.github.com>2018-09-17 13:46:06 +0300
committerGeorge Goldberg <george@gberg.me>2018-09-17 11:46:06 +0100
commit517faccc332ce48de43e597d1b2d29a3961241e7 (patch)
tree38470bb23b9547b8efca92d3341dd023f5f2e999 /app/import_functions.go
parent35c148d2551bbb65a6d469b44876ba78578397c1 (diff)
downloadchat-517faccc332ce48de43e597d1b2d29a3961241e7.tar.gz
chat-517faccc332ce48de43e597d1b2d29a3961241e7.tar.bz2
chat-517faccc332ce48de43e597d1b2d29a3961241e7.zip
MM-11424 Extend bulk import to support themes across teams(#9305) (#9419)
* MM-11424 Extend bulk import to support themes across teams(#9305) Also added: Advanced Settings: +'feature_enabled_markdown_preview' +'formatting' Sidebar Settings: +'show_unread_section' * MM-11424 (PR review) user teams' theme validator test updated * MM-11424 (PR review) added test with valid JSON of invalid theme(by structure) JSON string contains numeric and JSON object fields, not just a correct "string":"string" map
Diffstat (limited to 'app/import_functions.go')
-rw-r--r--app/import_functions.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/app/import_functions.go b/app/import_functions.go
index ff22f23bb..98306d3a7 100644
--- a/app/import_functions.go
+++ b/app/import_functions.go
@@ -555,6 +555,33 @@ func (a *App) ImportUser(data *UserImportData, dryRun bool) *model.AppError {
})
}
+ if data.UseMarkdownPreview != nil {
+ preferences = append(preferences, model.Preference{
+ UserId: savedUser.Id,
+ Category: model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS,
+ Name: "feature_enabled_markdown_preview",
+ Value: *data.UseMarkdownPreview,
+ })
+ }
+
+ if data.UseFormatting != nil {
+ preferences = append(preferences, model.Preference{
+ UserId: savedUser.Id,
+ Category: model.PREFERENCE_CATEGORY_ADVANCED_SETTINGS,
+ Name: "formatting",
+ Value: *data.UseFormatting,
+ })
+ }
+
+ if data.ShowUnreadSection != nil {
+ preferences = append(preferences, model.Preference{
+ UserId: savedUser.Id,
+ Category: model.PREFERENCE_CATEGORY_SIDEBAR_SETTINGS,
+ Name: "show_unread_section",
+ Value: *data.ShowUnreadSection,
+ })
+ }
+
if len(preferences) > 0 {
if result := <-a.Srv.Store.Preference().Save(&preferences); result.Err != nil {
return model.NewAppError("BulkImport", "app.import.import_user.save_preferences.error", nil, result.Err.Error(), http.StatusInternalServerError)
@@ -569,12 +596,23 @@ func (a *App) ImportUserTeams(user *model.User, data *[]UserTeamImportData) *mod
return nil
}
+ var teamThemePreferences model.Preferences
for _, tdata := range *data {
team, err := a.GetTeamByName(*tdata.Name)
if err != nil {
return err
}
+ // Team-specific theme Preferences.
+ if tdata.Theme != nil {
+ teamThemePreferences = append(teamThemePreferences, model.Preference{
+ UserId: user.Id,
+ Category: model.PREFERENCE_CATEGORY_THEME,
+ Name: team.Id,
+ Value: *tdata.Theme,
+ })
+ }
+
var roles string
isSchemeUser := true
isSchemeAdmin := false
@@ -622,6 +660,12 @@ func (a *App) ImportUserTeams(user *model.User, data *[]UserTeamImportData) *mod
}
}
+ if len(teamThemePreferences) > 0 {
+ if result := <-a.Srv.Store.Preference().Save(&teamThemePreferences); result.Err != nil {
+ return model.NewAppError("BulkImport", "app.import.import_user_teams.save_preferences.error", nil, result.Err.Error(), http.StatusInternalServerError)
+ }
+ }
+
return nil
}