Remove query to update channel extra_update_at field on user activation/deactivation (#8415)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
302dae5bb9
Коммит
8ad99b4b1f
@@ -914,10 +914,6 @@ func (a *App) UpdateActive(user *model.User, active bool) (*model.User, *model.A
|
||||
}
|
||||
}
|
||||
|
||||
if extra := <-a.Srv.Store.Channel().ExtraUpdateByUser(user.Id, model.GetMillis()); extra.Err != nil {
|
||||
return nil, extra.Err
|
||||
}
|
||||
|
||||
ruser := result.Data.([2]*model.User)[0]
|
||||
options := a.Config().GetSanitizeOptions()
|
||||
options["passwordupdate"] = false
|
||||
|
||||
@@ -1248,19 +1248,6 @@ func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType st
|
||||
})
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) ExtraUpdateByUser(userId string, time int64) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
_, err := s.GetMaster().Exec(
|
||||
`UPDATE Channels SET ExtraUpdateAt = :Time
|
||||
WHERE Id IN (SELECT ChannelId FROM ChannelMembers WHERE UserId = :UserId);`,
|
||||
map[string]interface{}{"UserId": userId, "Time": time})
|
||||
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.extraUpdated", "store.sql_channel.extra_updated.app_error", nil, "user_id="+userId+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
members := &model.ChannelMembers{}
|
||||
|
||||
@@ -153,7 +153,6 @@ type ChannelStore interface {
|
||||
UpdateLastViewedAt(channelIds []string, userId string) StoreChannel
|
||||
IncrementMentionCount(channelId string, userId string) StoreChannel
|
||||
AnalyticsTypeCount(teamId string, channelType string) StoreChannel
|
||||
ExtraUpdateByUser(userId string, time int64) StoreChannel
|
||||
GetMembersForUser(teamId string, userId string) StoreChannel
|
||||
AutocompleteInTeam(teamId string, term string) StoreChannel
|
||||
SearchInTeam(teamId string, term string) StoreChannel
|
||||
|
||||
@@ -43,7 +43,6 @@ func TestChannelStore(t *testing.T, ss store.Store) {
|
||||
t.Run("GetMember", func(t *testing.T) { testGetMember(t, ss) })
|
||||
t.Run("GetMemberForPost", func(t *testing.T) { testChannelStoreGetMemberForPost(t, ss) })
|
||||
t.Run("GetMemberCount", func(t *testing.T) { testGetMemberCount(t, ss) })
|
||||
t.Run("UpdateExtrasByUser", func(t *testing.T) { testUpdateExtrasByUser(t, ss) })
|
||||
t.Run("SearchMore", func(t *testing.T) { testChannelStoreSearchMore(t, ss) })
|
||||
t.Run("SearchInTeam", func(t *testing.T) { testChannelStoreSearchInTeam(t, ss) })
|
||||
t.Run("GetMembersByIds", func(t *testing.T) { testChannelStoreGetMembersByIds(t, ss) })
|
||||
@@ -1641,54 +1640,6 @@ func testGetMemberCount(t *testing.T, ss store.Store) {
|
||||
}
|
||||
}
|
||||
|
||||
func testUpdateExtrasByUser(t *testing.T, ss store.Store) {
|
||||
teamId := model.NewId()
|
||||
|
||||
c1 := model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel1",
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
store.Must(ss.Channel().Save(&c1, -1))
|
||||
|
||||
c2 := model.Channel{
|
||||
TeamId: teamId,
|
||||
DisplayName: "Channel2",
|
||||
Name: "zz" + model.NewId() + "b",
|
||||
Type: model.CHANNEL_OPEN,
|
||||
}
|
||||
store.Must(ss.Channel().Save(&c2, -1))
|
||||
|
||||
u1 := &model.User{
|
||||
Email: model.NewId(),
|
||||
DeleteAt: 0,
|
||||
}
|
||||
store.Must(ss.User().Save(u1))
|
||||
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1))
|
||||
|
||||
m1 := model.ChannelMember{
|
||||
ChannelId: c1.Id,
|
||||
UserId: u1.Id,
|
||||
NotifyProps: model.GetDefaultChannelNotifyProps(),
|
||||
}
|
||||
store.Must(ss.Channel().SaveMember(&m1))
|
||||
|
||||
u1.DeleteAt = model.GetMillis()
|
||||
store.Must(ss.User().Update(u1, true))
|
||||
|
||||
if result := <-ss.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil {
|
||||
t.Fatalf("failed to update extras by user: %v", result.Err)
|
||||
}
|
||||
|
||||
u1.DeleteAt = 0
|
||||
store.Must(ss.User().Update(u1, true))
|
||||
|
||||
if result := <-ss.Channel().ExtraUpdateByUser(u1.Id, u1.DeleteAt); result.Err != nil {
|
||||
t.Fatalf("failed to update extras by user: %v", result.Err)
|
||||
}
|
||||
}
|
||||
|
||||
func testChannelStoreSearchMore(t *testing.T, ss store.Store) {
|
||||
o1 := model.Channel{}
|
||||
o1.TeamId = model.NewId()
|
||||
|
||||
@@ -98,22 +98,6 @@ func (_m *ChannelStore) Delete(channelId string, time int64) store.StoreChannel
|
||||
return r0
|
||||
}
|
||||
|
||||
// ExtraUpdateByUser provides a mock function with given fields: userId, time
|
||||
func (_m *ChannelStore) ExtraUpdateByUser(userId string, time int64) store.StoreChannel {
|
||||
ret := _m.Called(userId, time)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
||||
r0 = rf(userId, time)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: id, allowFromCache
|
||||
func (_m *ChannelStore) Get(id string, allowFromCache bool) store.StoreChannel {
|
||||
ret := _m.Called(id, allowFromCache)
|
||||
|
||||
@@ -461,6 +461,22 @@ func (_m *TeamStore) UpdateDisplayName(name string, teamId string) store.StoreCh
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateLastTeamIconUpdate provides a mock function with given fields: teamId, curTime
|
||||
func (_m *TeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel {
|
||||
ret := _m.Called(teamId, curTime)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
||||
r0 = rf(teamId, curTime)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateMember provides a mock function with given fields: member
|
||||
func (_m *TeamStore) UpdateMember(member *model.TeamMember) store.StoreChannel {
|
||||
ret := _m.Called(member)
|
||||
@@ -476,19 +492,3 @@ func (_m *TeamStore) UpdateMember(member *model.TeamMember) store.StoreChannel {
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdateLastTeamIconUpdate provides a mock function with given fields: teamId
|
||||
func (_m *TeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) store.StoreChannel {
|
||||
ret := _m.Called(teamId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string, int64) store.StoreChannel); ok {
|
||||
r0 = rf(teamId, curTime)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user