made the preference store GetCategory method sync (#10847)

* made the preference store GetCategory method sync

* fixed the review comments
Этот коммит содержится в:
Pradeep Murugesan
2019-05-15 15:56:42 +01:00
коммит произвёл Christopher Speller
родитель 2130e9f0b1
Коммит 24a02b4168
6 изменённых файлов: 38 добавлений и 31 удалений

Просмотреть файл

@@ -19,16 +19,16 @@ func (a *App) GetPreferencesForUser(userId string) (model.Preferences, *model.Ap
}
func (a *App) GetPreferenceByCategoryForUser(userId string, category string) (model.Preferences, *model.AppError) {
result := <-a.Srv.Store.Preference().GetCategory(userId, category)
if result.Err != nil {
result.Err.StatusCode = http.StatusBadRequest
return nil, result.Err
preferences, err := a.Srv.Store.Preference().GetCategory(userId, category)
if err != nil {
err.StatusCode = http.StatusBadRequest
return nil, err
}
if len(result.Data.(model.Preferences)) == 0 {
if len(preferences) == 0 {
err := model.NewAppError("getPreferenceCategory", "api.preference.preferences_category.get.app_error", nil, "", http.StatusNotFound)
return nil, err
}
return result.Data.(model.Preferences), nil
return preferences, nil
}
func (a *App) GetPreferenceByCategoryAndNameForUser(userId string, category string, preferenceName string) (*model.Preference, *model.AppError) {