diff options
-rw-r--r-- | api/team.go | 4 | ||||
-rw-r--r-- | store/sql_channel_store.go | 17 | ||||
-rw-r--r-- | store/store.go | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/api/team.go b/api/team.go index eb8b0772d..35c770c20 100644 --- a/api/team.go +++ b/api/team.go @@ -599,6 +599,10 @@ func PermanentDeleteTeam(c *Context, team *model.Team) *model.AppError { } } + if result := <-Srv.Store.Channel().PermanentDeleteByTeam(team.Id); result.Err != nil { + return result.Err + } + if result := <-Srv.Store.Team().PermanentDelete(team.Id); result.Err != nil { return result.Err } diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index cc5c86107..badaa4d13 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -279,6 +279,23 @@ func (s SqlChannelStore) Delete(channelId string, time int64) StoreChannel { return storeChannel } +func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) StoreChannel { + storeChannel := make(StoreChannel) + + go func() { + result := StoreResult{} + + if _, err := s.GetMaster().Exec("DELETE FROM Channels WHERE TeamId = :TeamId", map[string]interface{}{"TeamId": teamId}); err != nil { + result.Err = model.NewAppError("SqlChannelStore.PermanentDeleteByTeam", "We couldn't delete the channels", "teamId="+teamId+", "+err.Error()) + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + type channelWithMember struct { model.Channel model.ChannelMember diff --git a/store/store.go b/store/store.go index a8b57dcdd..338ae186f 100644 --- a/store/store.go +++ b/store/store.go @@ -61,6 +61,7 @@ type ChannelStore interface { Update(channel *model.Channel) StoreChannel Get(id string) StoreChannel Delete(channelId string, time int64) StoreChannel + PermanentDeleteByTeam(teamId string) StoreChannel GetByName(team_id string, domain string) StoreChannel GetChannels(teamId string, userId string) StoreChannel GetMoreChannels(teamId string, userId string) StoreChannel |