[MM-16652] Migrate "User.ResetLastPictureUpdate" to Sync by default (#11474)

* [MM-16652] Migrate "User.ResetLastPictureUpdate" to Sync by default

* [Suggested Changes] Added mlog for error and removed return of userid
This commit is contained in:
Micah Thompson
2019-07-01 16:07:59 -04:00
committed by Jesús Espino
parent cff942f5bf
commit 0d5020e566
4 changed files with 14 additions and 14 deletions

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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)
}
}