diff --git a/app/user.go b/app/user.go index 8ea501f22b..c2dcdbfec4 100644 --- a/app/user.go +++ b/app/user.go @@ -839,7 +839,9 @@ func (a *App) SetDefaultProfileImage(user *model.User) *model.AppError { return err } - <-a.Srv.Store.User().ResetLastPictureUpdate(user.Id) + if err := a.Srv.Store.User().ResetLastPictureUpdate(user.Id); err != nil { + mlog.Error(err.Error()) + } a.InvalidateCacheForUser(user.Id) diff --git a/store/sqlstore/user_store.go b/store/sqlstore/user_store.go index bdacdf50b3..1aa97226c3 100644 --- a/store/sqlstore/user_store.go +++ b/store/sqlstore/user_store.go @@ -224,14 +224,12 @@ func (us SqlUserStore) UpdateLastPictureUpdate(userId string) store.StoreChannel }) } -func (us SqlUserStore) ResetLastPictureUpdate(userId string) store.StoreChannel { - return store.Do(func(result *store.StoreResult) { - if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = :Time, UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"Time": 0, "UserId": userId}); err != nil { - result.Err = model.NewAppError("SqlUserStore.ResetLastPictureUpdate", "store.sql_user.update_last_picture_update.app_error", nil, "user_id="+userId, http.StatusInternalServerError) - } else { - result.Data = userId - } - }) +func (us SqlUserStore) ResetLastPictureUpdate(userId string) *model.AppError { + if _, err := us.GetMaster().Exec("UPDATE Users SET LastPictureUpdate = :Time, UpdateAt = :Time WHERE Id = :UserId", map[string]interface{}{"Time": 0, "UserId": userId}); err != nil { + return model.NewAppError("SqlUserStore.ResetLastPictureUpdate", "store.sql_user.update_last_picture_update.app_error", nil, "user_id="+userId, http.StatusInternalServerError) + } + + return nil } func (us SqlUserStore) UpdateUpdateAt(userId string) store.StoreChannel { diff --git a/store/store.go b/store/store.go index 9536b63a9c..00c3776c9c 100644 --- a/store/store.go +++ b/store/store.go @@ -249,7 +249,7 @@ type UserStore interface { Save(user *model.User) StoreChannel Update(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, *model.AppError) UpdateLastPictureUpdate(userId string) StoreChannel - ResetLastPictureUpdate(userId string) StoreChannel + ResetLastPictureUpdate(userId string) *model.AppError UpdateUpdateAt(userId string) StoreChannel UpdatePassword(userId, newPassword string) StoreChannel UpdateAuthData(userId string, service string, authData *string, email string, resetMfa bool) (string, *model.AppError) diff --git a/store/storetest/mocks/UserStore.go b/store/storetest/mocks/UserStore.go index f32d1f4ae1..e859e71a2f 100644 --- a/store/storetest/mocks/UserStore.go +++ b/store/storetest/mocks/UserStore.go @@ -767,15 +767,15 @@ func (_m *UserStore) PermanentDelete(userId string) *model.AppError { } // ResetLastPictureUpdate provides a mock function with given fields: userId -func (_m *UserStore) ResetLastPictureUpdate(userId string) store.StoreChannel { +func (_m *UserStore) ResetLastPictureUpdate(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) } }