diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-10-16 08:11:03 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-10-16 08:11:03 -0400 |
commit | 269476d694f425764dbe0cccd4eaa3f23956ba61 (patch) | |
tree | f059aa16178e12fce04f3f71eca5557516e3fc4b /api/preference.go | |
parent | 7718783d0c57d46db00123379d3b8f9818bb791b (diff) | |
parent | b438eefad1a4303aeb5ab60214204c074e260224 (diff) | |
download | chat-269476d694f425764dbe0cccd4eaa3f23956ba61.tar.gz chat-269476d694f425764dbe0cccd4eaa3f23956ba61.tar.bz2 chat-269476d694f425764dbe0cccd4eaa3f23956ba61.zip |
Merge pull request #1078 from hmhealey/plt701
PLT-701 Removed preference migration code
Diffstat (limited to 'api/preference.go')
-rw-r--r-- | api/preference.go | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/api/preference.go b/api/preference.go index 88cb132f8..3a0535473 100644 --- a/api/preference.go +++ b/api/preference.go @@ -52,61 +52,10 @@ func getPreferenceCategory(c *Context, w http.ResponseWriter, r *http.Request) { } else { data := result.Data.(model.Preferences) - data = transformPreferences(c, data, category) - w.Write([]byte(data.ToJson())) } } -func transformPreferences(c *Context, preferences model.Preferences, category string) model.Preferences { - if len(preferences) == 0 && category == model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW { - // add direct channels for a user that existed before preferences were added - preferences = addDirectChannels(c.Session.UserId, c.Session.TeamId) - } - - return preferences -} - -func addDirectChannels(userId, teamId string) model.Preferences { - var profiles map[string]*model.User - if result := <-Srv.Store.User().GetProfiles(teamId); result.Err != nil { - l4g.Error("Failed to add direct channel preferences for user user_id=%s, team_id=%s, err=%v", userId, teamId, result.Err.Error()) - return model.Preferences{} - } else { - profiles = result.Data.(map[string]*model.User) - } - - var preferences model.Preferences - - for id := range profiles { - if id == userId { - continue - } - - profile := profiles[id] - - preference := model.Preference{ - UserId: userId, - Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, - Name: profile.Id, - Value: "true", - } - - preferences = append(preferences, preference) - - if len(preferences) >= 10 { - break - } - } - - if result := <-Srv.Store.Preference().Save(&preferences); result.Err != nil { - l4g.Error("Failed to add direct channel preferences for user user_id=%s, eam_id=%s, err=%v", userId, teamId, result.Err.Error()) - return model.Preferences{} - } else { - return preferences - } -} - func getPreference(c *Context, w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) category := params["category"] |