Migrate "Team.UpdateLastTeamIconUpdate" to Sync by default (#11561)
Этот коммит содержится в:
коммит произвёл
jfrerich
родитель
4380c0b7a8
Коммит
7663c5b00e
@@ -1282,8 +1282,8 @@ func (a *App) SetTeamIconFromFile(team *model.Team, file io.Reader) *model.AppEr
|
||||
|
||||
curTime := model.GetMillis()
|
||||
|
||||
if result := <-a.Srv.Store.Team().UpdateLastTeamIconUpdate(team.Id, curTime); result.Err != nil {
|
||||
return model.NewAppError("SetTeamIcon", "api.team.team_icon.update.app_error", nil, result.Err.Error(), http.StatusBadRequest)
|
||||
if err := a.Srv.Store.Team().UpdateLastTeamIconUpdate(team.Id, curTime); err != nil {
|
||||
return model.NewAppError("SetTeamIcon", "api.team.team_icon.update.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// manually set time to avoid possible cluster inconsistencies
|
||||
@@ -1300,8 +1300,8 @@ func (a *App) RemoveTeamIcon(teamId string) *model.AppError {
|
||||
return model.NewAppError("RemoveTeamIcon", "api.team.remove_team_icon.get_team.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if result := <-a.Srv.Store.Team().UpdateLastTeamIconUpdate(teamId, 0); result.Err != nil {
|
||||
return model.NewAppError("RemoveTeamIcon", "api.team.team_icon.update.app_error", nil, result.Err.Error(), http.StatusBadRequest)
|
||||
if err := a.Srv.Store.Team().UpdateLastTeamIconUpdate(teamId, 0); err != nil {
|
||||
return model.NewAppError("RemoveTeamIcon", "api.team.team_icon.update.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
team.LastTeamIconUpdate = 0
|
||||
|
||||
@@ -794,14 +794,11 @@ func (s SqlTeamStore) RemoveAllMembersByUser(userId string) store.StoreChannel {
|
||||
})
|
||||
}
|
||||
|
||||
func (us SqlTeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
if _, err := us.GetMaster().Exec("UPDATE Teams SET LastTeamIconUpdate = :Time, UpdateAt = :Time WHERE Id = :teamId", map[string]interface{}{"Time": curTime, "teamId": teamId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.UpdateLastTeamIconUpdate", "store.sql_team.update_last_team_icon_update.app_error", nil, "team_id="+teamId, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
result.Data = teamId
|
||||
})
|
||||
func (us SqlTeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) *model.AppError {
|
||||
if _, err := us.GetMaster().Exec("UPDATE Teams SET LastTeamIconUpdate = :Time, UpdateAt = :Time WHERE Id = :teamId", map[string]interface{}{"Time": curTime, "teamId": teamId}); err != nil {
|
||||
return model.NewAppError("SqlTeamStore.UpdateLastTeamIconUpdate", "store.sql_team.update_last_team_icon_update.app_error", nil, "team_id="+teamId, http.StatusInternalServerError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetTeamsByScheme(schemeId string, offset int, limit int) store.StoreChannel {
|
||||
|
||||
@@ -114,7 +114,7 @@ type TeamStore interface {
|
||||
RemoveMember(teamId string, userId string) StoreChannel
|
||||
RemoveAllMembersByTeam(teamId string) StoreChannel
|
||||
RemoveAllMembersByUser(userId string) StoreChannel
|
||||
UpdateLastTeamIconUpdate(teamId string, curTime int64) StoreChannel
|
||||
UpdateLastTeamIconUpdate(teamId string, curTime int64) *model.AppError
|
||||
GetTeamsByScheme(schemeId string, offset int, limit int) StoreChannel
|
||||
MigrateTeamMembers(fromTeamId string, fromUserId string) StoreChannel
|
||||
ResetAllTeamSchemes() StoreChannel
|
||||
|
||||
@@ -874,15 +874,15 @@ func (_m *TeamStore) UpdateDisplayName(name string, teamId string) *model.AppErr
|
||||
}
|
||||
|
||||
// UpdateLastTeamIconUpdate provides a mock function with given fields: teamId, curTime
|
||||
func (_m *TeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel {
|
||||
func (_m *TeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) *model.AppError {
|
||||
ret := _m.Called(teamId, curTime)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string, int64) *model.AppError); ok {
|
||||
r0 = rf(teamId, curTime)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1291,7 +1291,7 @@ func testUpdateLastTeamIconUpdate(t *testing.T, ss store.Store) {
|
||||
|
||||
curTime := model.GetMillis()
|
||||
|
||||
if err = (<-ss.Team().UpdateLastTeamIconUpdate(o1.Id, curTime)).Err; err != nil {
|
||||
if err = ss.Team().UpdateLastTeamIconUpdate(o1.Id, curTime); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user