Migrates Channel.PermanentDeleteMembersByChannel to sync by default (#11238)

Этот коммит содержится в:
Rodrigo Villablanca Vásquez
2019-06-18 12:33:42 -04:00
коммит произвёл Miguel Alatzar
родитель 075eadb040
Коммит d1569c48d2
6 изменённых файлов: 20 добавлений и 20 удалений

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

@@ -1916,8 +1916,8 @@ func (a *App) PermanentDeleteChannel(channel *model.Channel) *model.AppError {
return err return err
} }
if result := <-a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); result.Err != nil { if err := a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); err != nil {
return result.Err return err
} }
if err := a.Srv.Store.Webhook().PermanentDeleteIncomingByChannel(channel.Id); err != nil { 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) { func removeAllUsersFromChannel(a *app.App, channel *model.Channel) {
if result := <-a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); result.Err != nil { if err := a.Srv.Store.Channel().PermanentDeleteMembersByChannel(channel.Id); err != nil {
CommandPrintErrorln("Unable to remove all users from " + channel.Name + ". Error: " + result.Err.Error()) 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 return result
} }
func (s SqlChannelStore) PermanentDeleteMembersByChannel(channelId string) store.StoreChannel { func (s SqlChannelStore) PermanentDeleteMembersByChannel(channelId string) *model.AppError {
return store.Do(func(result *store.StoreResult) { _, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId})
_, err := s.GetMaster().Exec("DELETE FROM ChannelMembers WHERE ChannelId = :ChannelId", map[string]interface{}{"ChannelId": channelId}) if err != nil {
if err != nil { return model.NewAppError("SqlChannelStore.RemoveAllMembersByChannel", "store.sql_channel.remove_member.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError)
result.Err = 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 { func (s SqlChannelStore) GetChannels(teamId string, userId string, includeDeleted bool) store.StoreChannel {

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

@@ -174,7 +174,7 @@ type ChannelStore interface {
GetPinnedPosts(channelId string) StoreChannel GetPinnedPosts(channelId string) StoreChannel
RemoveMember(channelId string, userId string) StoreChannel RemoveMember(channelId string, userId string) StoreChannel
PermanentDeleteMembersByUser(userId string) StoreChannel PermanentDeleteMembersByUser(userId string) StoreChannel
PermanentDeleteMembersByChannel(channelId string) StoreChannel PermanentDeleteMembersByChannel(channelId string) *model.AppError
UpdateLastViewedAt(channelIds []string, userId string) StoreChannel UpdateLastViewedAt(channelIds []string, userId string) StoreChannel
IncrementMentionCount(channelId string, userId string) StoreChannel IncrementMentionCount(channelId string, userId string) StoreChannel
AnalyticsTypeCount(teamId string, channelType string) (int64, *model.AppError) 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) t.Fatal("couldn't create direct channel", err)
} }
defer func() { defer func() {
<-ss.Channel().PermanentDeleteMembersByChannel(c1.Id) ss.Channel().PermanentDeleteMembersByChannel(c1.Id)
<-ss.Channel().PermanentDelete(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") t.Fatal("should have removed 1 member")
} }
if r1 := <-ss.Channel().PermanentDeleteMembersByChannel(o1.ChannelId); r1.Err != nil { if err := ss.Channel().PermanentDeleteMembersByChannel(o1.ChannelId); err != nil {
t.Fatal(r1.Err) t.Fatal(err)
} }
count = (<-ss.Channel().GetMemberCount(o1.ChannelId, false)).Data.(int64) 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()) t.Fatalf(err.Error())
} }
defer func() { defer func() {
<-ss.Channel().PermanentDeleteMembersByChannel(d4.Id) ss.Channel().PermanentDeleteMembersByChannel(d4.Id)
<-ss.Channel().PermanentDelete(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 // 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) 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)
} }
} }