Migrate Channel.RemoveAllDeactivatedMembers to Sync by default (#11270)

* Migrate Channel.RemoveAllDeactivatedMembers to Sync by default

* Indent query string
Этот коммит содержится в:
Shobhit Gupta
2019-06-18 14:09:15 -07:00
коммит произвёл Jesús Espino
родитель 6555bea117
Коммит e92ecf6696
5 изменённых файлов: 30 добавлений и 31 удалений

Просмотреть файл

@@ -1693,30 +1693,29 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) *model.Ap
return nil
}
func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
query := `
DELETE
FROM
ChannelMembers
WHERE
UserId IN (
SELECT
Id
FROM
Users
WHERE
Users.DeleteAt != 0
)
AND
ChannelMembers.ChannelId = :ChannelId
`
func (s SqlChannelStore) RemoveAllDeactivatedMembers(channelId string) *model.AppError {
query := `
DELETE
FROM
ChannelMembers
WHERE
UserId IN (
SELECT
Id
FROM
Users
WHERE
Users.DeleteAt != 0
)
AND
ChannelMembers.ChannelId = :ChannelId
`
_, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId})
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)
}
})
_, err := s.GetMaster().Exec(query, map[string]interface{}{"ChannelId": channelId})
if err != nil {
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 {