Channel.GetTeamChannels to sync by default (#11211)

Этот коммит содержится в:
Rodrigo Villablanca Vásquez
2019-06-18 01:22:37 -04:00
коммит произвёл Hanzei
родитель 7d08efc335
Коммит a7278169d2
7 изменённых файлов: 38 добавлений и 35 удалений

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

@@ -1133,23 +1133,19 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) (*model.
return counts, nil
}
func (s SqlChannelStore) GetTeamChannels(teamId string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
data := &model.ChannelList{}
_, err := s.GetReplica().Select(data, "SELECT * FROM Channels WHERE TeamId = :TeamId And Type != 'D' ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId})
func (s SqlChannelStore) GetTeamChannels(teamId string) (*model.ChannelList, *model.AppError) {
data := &model.ChannelList{}
_, err := s.GetReplica().Select(data, "SELECT * FROM Channels WHERE TeamId = :TeamId And Type != 'D' ORDER BY DisplayName", map[string]interface{}{"TeamId": teamId})
if err != nil {
result.Err = model.NewAppError("SqlChannelStore.GetTeamChannels", "store.sql_channel.get_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError)
return
}
if err != nil {
return nil, model.NewAppError("SqlChannelStore.GetTeamChannels", "store.sql_channel.get_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error(), http.StatusInternalServerError)
}
if len(*data) == 0 {
result.Err = model.NewAppError("SqlChannelStore.GetTeamChannels", "store.sql_channel.get_channels.not_found.app_error", nil, "teamId="+teamId, http.StatusNotFound)
return
}
if len(*data) == 0 {
return nil, model.NewAppError("SqlChannelStore.GetTeamChannels", "store.sql_channel.get_channels.not_found.app_error", nil, "teamId="+teamId, http.StatusNotFound)
}
result.Data = data
})
return data, nil
}
func (s SqlChannelStore) GetByName(teamId string, name string, allowFromCache bool) store.StoreChannel {

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

@@ -153,7 +153,7 @@ type ChannelStore interface {
GetPublicChannelsForTeam(teamId string, offset int, limit int) StoreChannel
GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) StoreChannel
GetChannelCounts(teamId string, userId string) (*model.ChannelCounts, *model.AppError)
GetTeamChannels(teamId string) StoreChannel
GetTeamChannels(teamId string) (*model.ChannelList, *model.AppError)
GetAll(teamId string) StoreChannel
GetChannelsByIds(channelIds []string) ([]*model.Channel, *model.AppError)
GetForPost(postId string) StoreChannel

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

@@ -432,10 +432,9 @@ func testChannelStoreGet(t *testing.T, ss store.Store, s SqlSupplier) {
}
}
if r3 := <-ss.Channel().GetTeamChannels(o1.TeamId); r3.Err != nil {
t.Fatal(r3.Err)
if channels, err := ss.Channel().GetTeamChannels(o1.TeamId); err != nil {
t.Fatal(err)
} else {
channels := r3.Data.(*model.ChannelList)
if len(*channels) == 0 {
t.Fatal("too little")
}

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

@@ -779,19 +779,28 @@ func (_m *ChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limi
}
// GetTeamChannels provides a mock function with given fields: teamId
func (_m *ChannelStore) GetTeamChannels(teamId string) store.StoreChannel {
func (_m *ChannelStore) GetTeamChannels(teamId string) (*model.ChannelList, *model.AppError) {
ret := _m.Called(teamId)
var r0 store.StoreChannel
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
var r0 *model.ChannelList
if rf, ok := ret.Get(0).(func(string) *model.ChannelList); ok {
r0 = rf(teamId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(store.StoreChannel)
r0 = ret.Get(0).(*model.ChannelList)
}
}
return r0
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
r1 = rf(teamId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
}
}
return r0, r1
}
// IncrementMentionCount provides a mock function with given fields: channelId, userId