mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Migrates Channel.PermanentDeleteMembersByChannel to sync by default (#11238)
This commit is contained in:
committed by
Miguel Alatzar
parent
075eadb040
commit
d1569c48d2
@@ -1916,8 +1916,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
if result := <-a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); result.Err != nil {
|
||||
return result.Err
|
||||
if err := a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := a.Srv.Store.Webhook().PermanentDeleteIncomingByChannel(channel.Id); err != nil {
|
||||
|
||||
@@ -265,8 +265,8 @@ func removeUserFromChannel(a *app.App, channel *model.Channel, user *model.User,
|
||||
}
|
||||
|
||||
func removeAllUsersFromChannel(a *app.App, channel *model.Channel) {
|
||||
if result := <-a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); result.Err != nil {
|
||||
CommandPrintErrorln("Unable to remove all users from " + channel.Name + ". Error: " + result.Err.Error())
|
||||
if err := a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); err != nil {
|
||||
CommandPrintErrorln("Unable to remove all users from " + channel.Name + ". Error: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -920,13 +920,13 @@ func (s SqlChannelStore) permanentDeleteT(transaction *gorp.Transaction, channel
|
||||
return result
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) PermanentDeleteMembersByChannel(channelId string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
_, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.RemoveAllMembersByChannel", "store.sql_channel.remove_member.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
})
|
||||
func (s SqlChannelStore) PermanentDeleteMembersByChannel(channelId string) *model.AppError {
|
||||
_, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
|
||||
if err != nil {
|
||||
return model.NewAppError("SqlChannelStore.RemoveAllMembersByChannel", "store.sql_channel.remove_member.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) GetChannels(teamId string, userId string, includeDeleted bool) store.StoreChannel {
|
||||
|
||||
@@ -174,7 +174,7 @@ type ChannelStore interface {
|
||||
GetPinnedPosts(channelId string) StoreChannel
|
||||
RemoveMember(channelId string, userId string) StoreChannel
|
||||
PermanentDeleteMembersByUser(userId string) StoreChannel
|
||||
PermanentDeleteMembersByChannel(channelId string) StoreChannel
|
||||
PermanentDeleteMembersByChannel(channelId string) *model.AppError
|
||||
UpdateLastViewedAt(channelIds []string, userId string) StoreChannel
|
||||
IncrementMentionCount(channelId string, userId string) StoreChannel
|
||||
AnalyticsTypeCount(teamId string, channelType string) (int64, *model.AppError)
|
||||
|
||||
@@ -223,7 +223,7 @@ func testChannelStoreCreateDirectChannel(t *testing.T, ss store.Store) {
|
||||
t.Fatal("couldn't create direct channel", err)
|
||||
}
|
||||
defer func() {
|
||||
<-ss.Channel().PermanentDeleteMembersByChannel(c1.Id)
|
||||
ss.Channel().PermanentDeleteMembersByChannel(c1.Id)
|
||||
<-ss.Channel().PermanentDelete(c1.Id)
|
||||
}()
|
||||
|
||||
@@ -984,8 +984,8 @@ func testChannelDeleteMemberStore(t *testing.T, ss store.Store) {
|
||||
t.Fatal("should have removed 1 member")
|
||||
}
|
||||
|
||||
if r1 := <-ss.Channel().PermanentDeleteMembersByChannel(o1.ChannelId); r1.Err != nil {
|
||||
t.Fatal(r1.Err)
|
||||
if err := ss.Channel().PermanentDeleteMembersByChannel(o1.ChannelId); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
count = (<-ss.Channel().GetMemberCount(o1.ChannelId, false)).Data.(int64)
|
||||
@@ -2750,7 +2750,7 @@ func testChannelStoreAnalyticsDeletedTypeCount(t *testing.T, ss store.Store) {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
defer func() {
|
||||
<-ss.Channel().PermanentDeleteMembersByChannel(d4.Id)
|
||||
ss.Channel().PermanentDeleteMembersByChannel(d4.Id)
|
||||
<-ss.Channel().PermanentDelete(d4.Id)
|
||||
}()
|
||||
|
||||
|
||||
@@ -930,15 +930,15 @@ func (_m *ChannelStore) PermanentDeleteByTeam(teamId string) store.StoreChannel
|
||||
}
|
||||
|
||||
// PermanentDeleteMembersByChannel provides a mock function with given fields: channelId
|
||||
func (_m *ChannelStore) PermanentDeleteMembersByChannel(channelId string) store.StoreChannel {
|
||||
func (_m *ChannelStore) PermanentDeleteMembersByChannel(channelId string) *model.AppError {
|
||||
ret := _m.Called(channelId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func(string) *model.AppError); ok {
|
||||
r0 = rf(channelId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user