diff --git a/app/user.go b/app/user.go index d2ae4f893c..4633ac526f 100644 --- a/app/user.go +++ b/app/user.go @@ -904,7 +904,9 @@ func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppE return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.upload_profile.app_error", nil, "", http.StatusInternalServerError) } - <-a.Srv.Store.User().UpdateLastPictureUpdate(userId) + if err := a.Srv.Store.User().UpdateLastPictureUpdate(userId); err != nil { + mlog.Error(err.Error()) + } a.InvalidateCacheForUser(userId) diff --git a/store/sqlstore/user_store.go b/store/sqlstore/user_store.go index e0a4300aa1..28b60408bb 100644 --- a/store/sqlstore/user_store.go +++ b/store/sqlstore/user_store.go @@ -212,16 +212,14 @@ func (us SqlUserStore) Update(user *model.User, trustedUpdateData bool) (*model. return &model.UserUpdate{New: user, Old: oldUser}, nil } -func (us SqlUserStore) UpdateLastPictureUpdate(userId string) store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - curTime := model.GetMillis() +func (us SqlUserStore) UpdateLastPictureUpdate(userId string) *model.AppError { + curTime := model.GetMillis() - if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = :Time, UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"Time": curTime, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.UpdateLastPictureUpdate", "store.sql_user.update_last_picture_update.app_error", nil, "user_id="+userId, http.StatusInternalServerError) - } else { - result.Data = userId - } - }) + if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = :Time, UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"Time": curTime, "UserId": userId}); err != nil { + return model.NewAppError("SqlUserStore.UpdateLastPictureUpdate", "store.sql_user.update_last_picture_update.app_error", nil, "user_id="+userId, http.StatusInternalServerError) + } + + return nil } func (us SqlUserStore) ResetLastPictureUpdate(userId string) *model.AppError { diff --git a/store/store.go b/store/store.go index 05a10fd987..c5cff2b1f4 100644 --- a/store/store.go +++ b/store/store.go @@ -251,7 +251,7 @@ type PostStore interface { type UserStore interface { Save(user *model.User) StoreChannel Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, *model.AppError) - UpdateLastPictureUpdate(userId string) StoreChannel + UpdateLastPictureUpdate(userId string) *model.AppError ResetLastPictureUpdate(userId string) *model.AppError UpdateUpdateAt(userId string) StoreChannel UpdatePassword(userId, newPassword string) StoreChannel diff --git a/store/storetest/mocks/UserStore.go b/store/storetest/mocks/UserStore.go index a9a1c4e4e0..e822d056f7 100644 --- a/store/storetest/mocks/UserStore.go +++ b/store/storetest/mocks/UserStore.go @@ -1043,15 +1043,15 @@ func (_m *UserStore) UpdateFailedPasswordAttempts(userId string, attempts int) s } // UpdateLastPictureUpdate provides a mock function with given fields: userId -func (_m *UserStore) UpdateLastPictureUpdate(userId string) store.StoreChannel { +func (_m *UserStore) UpdateLastPictureUpdate(userId string) *model.AppError { ret := _m.Called(userId) - var r0 store.StoreChannel - if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok { + var r0 *model.AppError + if rf, ok := ret.Get(0).(func(string) *model.AppError); ok { r0 = rf(userId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(store.StoreChannel) + r0 = ret.Get(0).(*model.AppError) } } diff --git a/store/storetest/user_store.go b/store/storetest/user_store.go index d82025343a..4f4c3487f7 100644 --- a/store/storetest/user_store.go +++ b/store/storetest/user_store.go @@ -203,7 +203,7 @@ func testUserStoreUpdate(t *testing.T, ss store.Store) { } } - if result := <-ss.User().UpdateLastPictureUpdate(u1.Id); result.Err != nil { + if err := ss.User().UpdateLastPictureUpdate(u1.Id); err != nil { t.Fatal("Update should not have failed") } }