Migrate Channel.RemoveAllDeactivatedMembers to Sync by default (#11270)
* Migrate Channel.RemoveAllDeactivatedMembers to Sync by default * Indent query string
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
6555bea117
Коммит
e92ecf6696
@@ -1956,8 +1956,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
|
|||||||
// is in progress, and therefore should not be used from the API without first fixing this potential race condition.
|
// is in progress, and therefore should not be used from the API without first fixing this potential race condition.
|
||||||
func (a *App) MoveChannel(team *model.Team, channel *model.Channel, user *model.User, removeDeactivatedMembers bool) *model.AppError {
|
func (a *App) MoveChannel(team *model.Team, channel *model.Channel, user *model.User, removeDeactivatedMembers bool) *model.AppError {
|
||||||
if removeDeactivatedMembers {
|
if removeDeactivatedMembers {
|
||||||
if result := <-a.Srv.Store.Channel().RemoveAllDeactivatedMembers(channel.Id); result.Err != nil {
|
if err := a.Srv.Store.Channel().RemoveAllDeactivatedMembers(channel.Id); err != nil {
|
||||||
return result.Err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1693,30 +1693,29 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) *model.Ap
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) store.StoreChannel {
|
func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
query := `
|
||||||
query := `
|
DELETE
|
||||||
DELETE
|
FROM
|
||||||
FROM
|
ChannelMembers
|
||||||
ChannelMembers
|
WHERE
|
||||||
WHERE
|
UserId IN (
|
||||||
UserId IN (
|
SELECT
|
||||||
SELECT
|
Id
|
||||||
Id
|
FROM
|
||||||
FROM
|
Users
|
||||||
Users
|
WHERE
|
||||||
WHERE
|
Users.DeleteAt != 0
|
||||||
Users.DeleteAt != 0
|
)
|
||||||
)
|
AND
|
||||||
AND
|
ChannelMembers.ChannelId = :ChannelId
|
||||||
ChannelMembers.ChannelId = :ChannelId
|
`
|
||||||
`
|
|
||||||
|
|
||||||
_, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId})
|
_, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlChannelStore.RemoveAllDeactivatedMembers", "store.sql_channel.remove_all_deactivated_members.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError)
|
return model.NewAppError("SqlChannelStore.RemoveAllDeactivatedMembers", "store.sql_channel.remove_all_deactivated_members.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
})
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) store.StoreChannel {
|
func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) store.StoreChannel {
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ type ChannelStore interface {
|
|||||||
GetAllChannelsForExportAfter(limit int, afterId string) StoreChannel
|
GetAllChannelsForExportAfter(limit int, afterId string) StoreChannel
|
||||||
GetAllDirectChannelsForExportAfter(limit int, afterId string) StoreChannel
|
GetAllDirectChannelsForExportAfter(limit int, afterId string) StoreChannel
|
||||||
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError)
|
GetChannelMembersForExport(userId string, teamId string) ([]*model.ChannelMemberForExport, *model.AppError)
|
||||||
RemoveAllDeactivatedMembers(channelId string) StoreChannel
|
RemoveAllDeactivatedMembers(channelId string) *model.AppError
|
||||||
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError)
|
GetChannelsBatchForIndexing(startTime, endTime int64, limit int) ([]*model.Channel, *model.AppError)
|
||||||
UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError)
|
UserBelongsToChannels(userId string, channelIds []string) (bool, *model.AppError)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3426,7 +3426,7 @@ func testChannelStoreRemoveAllDeactivatedMembers(t *testing.T, ss store.Store) {
|
|||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
// Remove all deactivated users from the channel.
|
// Remove all deactivated users from the channel.
|
||||||
assert.Nil(t, (<-ss.Channel().RemoveAllDeactivatedMembers(c1.Id)).Err)
|
assert.Nil(t, ss.Channel().RemoveAllDeactivatedMembers(c1.Id))
|
||||||
|
|
||||||
// Get all the channel members. Check there is now only 1: m3.
|
// Get all the channel members. Check there is now only 1: m3.
|
||||||
r2 := <-ss.Channel().GetMembers(c1.Id, 0, 1000)
|
r2 := <-ss.Channel().GetMembers(c1.Id, 0, 1000)
|
||||||
|
|||||||
@@ -980,15 +980,15 @@ func (_m *ChannelStore) PermanentDeleteMembersByUser(userId string) store.StoreC
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveAllDeactivatedMembers provides a mock function with given fields: channelId
|
// RemoveAllDeactivatedMembers provides a mock function with given fields: channelId
|
||||||
func (_m *ChannelStore) RemoveAllDeactivatedMembers(channelId string) store.StoreChannel {
|
func (_m *ChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError {
|
||||||
ret := _m.Called(channelId)
|
ret := _m.Called(channelId)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.AppError
|
||||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||||
r0 = rf(channelId)
|
r0 = rf(channelId)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.AppError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user