[MM-15297] Migrate "Preference.Get" to Sync by default #10721 (#10811)

* modify Get method in preference_store

* modify interface to match changes on preference store Get method

* modify variable initialization

* fix behavior on GetPreferenceByCategoryAndNameForUser
Этот коммит содержится в:
Ivana Irene Thomas
2019-05-15 19:20:26 +07:00
коммит произвёл Miguel de la Cruz
родитель b3e09715df
Коммит a68ad55151
8 изменённых файлов: 56 добавлений и 52 удалений

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

@@ -171,13 +171,11 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
// get how long we need to wait to send notifications to the user
var interval int64
pchan := job.server.Store.Preference().Get(userId, model.PREFERENCE_CATEGORY_NOTIFICATIONS, model.PREFERENCE_NAME_EMAIL_INTERVAL)
if result := <-pchan; result.Err != nil {
preference, err := job.server.Store.Preference().Get(userId, model.PREFERENCE_CATEGORY_NOTIFICATIONS, model.PREFERENCE_NAME_EMAIL_INTERVAL)
if err != nil {
// use the default batching interval if an error ocurrs while fetching user preferences
interval, _ = strconv.ParseInt(model.PREFERENCE_EMAIL_INTERVAL_BATCHING_SECONDS, 10, 64)
} else {
preference := result.Data.(model.Preference)
if value, err := strconv.ParseInt(preference.Value, 10, 64); err != nil {
// // use the default batching interval if an error ocurrs while deserializing user preferences
interval, _ = strconv.ParseInt(model.PREFERENCE_EMAIL_INTERVAL_BATCHING_SECONDS, 10, 64)