коммит произвёл
Jesús Espino
родитель
45b47ca901
Коммит
d1a594e504
@@ -825,49 +825,42 @@ func (s SqlChannelStore) setDeleteAtT(transaction *gorp.Transaction, channelId s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PermanentDeleteByTeam removes all channels for the given team from the database.
|
// PermanentDeleteByTeam removes all channels for the given team from the database.
|
||||||
func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) store.StoreChannel {
|
func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) *model.AppError {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
transaction, err := s.GetMaster().Begin()
|
||||||
transaction, err := s.GetMaster().Begin()
|
if err != nil {
|
||||||
if err != nil {
|
return model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "store.sql_channel.permanent_delete_by_team.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
result.Err = model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "store.sql_channel.permanent_delete_by_team.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
}
|
||||||
return
|
defer finalizeTransaction(transaction)
|
||||||
}
|
|
||||||
defer finalizeTransaction(transaction)
|
|
||||||
|
|
||||||
*result = s.permanentDeleteByTeamtT(transaction, teamId)
|
if err := s.permanentDeleteByTeamtT(transaction, teamId); err != nil {
|
||||||
if result.Err != nil {
|
return err
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Additionally propagate the deletions to the PublicChannels table.
|
// Additionally propagate the deletions to the PublicChannels table.
|
||||||
if _, err := transaction.Exec(`
|
if _, err := transaction.Exec(`
|
||||||
DELETE FROM
|
DELETE FROM
|
||||||
PublicChannels
|
PublicChannels
|
||||||
WHERE
|
WHERE
|
||||||
TeamId = :TeamId
|
TeamId = :TeamId
|
||||||
`, map[string]interface{}{
|
`, map[string]interface{}{
|
||||||
"TeamId": teamId,
|
"TeamId": teamId,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
result.Err = model.NewAppError("SqlChannelStore.PermanentDeleteByTeamt", "store.sql_channel.permanent_delete_by_team.delete_public_channels.app_error", nil, "team_id="+teamId+", "+err.Error(), http.StatusInternalServerError)
|
return model.NewAppError("SqlChannelStore.PermanentDeleteByTeamt", "store.sql_channel.permanent_delete_by_team.delete_public_channels.app_error", nil, "team_id="+teamId+", "+err.Error(), http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := transaction.Commit(); err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "store.sql_channel.permanent_delete_by_team.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s SqlChannelStore) permanentDeleteByTeamtT(transaction *gorp.Transaction, teamId string) store.StoreResult {
|
|
||||||
result := store.StoreResult{}
|
|
||||||
|
|
||||||
if _, err := transaction.Exec("DELETE FROM Channels WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil {
|
|
||||||
result.Err = model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "store.sql_channel.permanent_delete_by_team.app_error", nil, "teamId="+teamId+", "+err.Error(), http.StatusInternalServerError)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
if err := transaction.Commit(); err != nil {
|
||||||
|
return model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "store.sql_channel.permanent_delete_by_team.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SqlChannelStore) permanentDeleteByTeamtT(transaction *gorp.Transaction, teamId string) *model.AppError {
|
||||||
|
if _, err := transaction.Exec("DELETE FROM Channels WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil {
|
||||||
|
return model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "store.sql_channel.permanent_delete_by_team.app_error", nil, "teamId="+teamId+", "+err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PermanentDelete removes the given channel from the database.
|
// PermanentDelete removes the given channel from the database.
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ type ChannelStore interface {
|
|||||||
Delete(channelId string, time int64) *model.AppError
|
Delete(channelId string, time int64) *model.AppError
|
||||||
Restore(channelId string, time int64) *model.AppError
|
Restore(channelId string, time int64) *model.AppError
|
||||||
SetDeleteAt(channelId string, deleteAt int64, updateAt int64) *model.AppError
|
SetDeleteAt(channelId string, deleteAt int64, updateAt int64) *model.AppError
|
||||||
PermanentDeleteByTeam(teamId string) StoreChannel
|
PermanentDeleteByTeam(teamId string) *model.AppError
|
||||||
PermanentDelete(channelId string) StoreChannel
|
PermanentDelete(channelId string) StoreChannel
|
||||||
GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, *model.AppError)
|
GetByName(team_id string, name string, allowFromCache bool) (*model.Channel, *model.AppError)
|
||||||
GetByNames(team_id string, names []string, allowFromCache bool) ([]*model.Channel, *model.AppError)
|
GetByNames(team_id string, names []string, allowFromCache bool) ([]*model.Channel, *model.AppError)
|
||||||
|
|||||||
@@ -645,8 +645,8 @@ func testChannelStoreDelete(t *testing.T, ss store.Store) {
|
|||||||
require.Equal(t, &model.ChannelList{}, list)
|
require.Equal(t, &model.ChannelList{}, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
if r := <-ss.Channel().PermanentDeleteByTeam(o1.TeamId); r.Err != nil {
|
if err = ss.Channel().PermanentDeleteByTeam(o1.TeamId); err != nil {
|
||||||
t.Fatal(r.Err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1158,15 +1158,15 @@ func (_m *ChannelStore) PermanentDelete(channelId string) store.StoreChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PermanentDeleteByTeam provides a mock function with given fields: teamId
|
// PermanentDeleteByTeam provides a mock function with given fields: teamId
|
||||||
func (_m *ChannelStore) PermanentDeleteByTeam(teamId string) store.StoreChannel {
|
func (_m *ChannelStore) PermanentDeleteByTeam(teamId string) *model.AppError {
|
||||||
ret := _m.Called(teamId)
|
ret := _m.Called(teamId)
|
||||||
|
|
||||||
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(teamId)
|
r0 = rf(teamId)
|
||||||
} 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