From be17e05d7322f9c6e6cbf93bff1cfca63b73aa76 Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 10 Nov 2016 11:23:55 -0300 Subject: PLT-4665 Fix Max Channels limit wrong count (#4512) --- store/sql_channel_store.go | 26 ++++++++++++++++++++++++++ store/store.go | 1 + 2 files changed, 27 insertions(+) (limited to 'store') diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index 5107a0bd8..aadeed7c3 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -464,6 +464,32 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreCha return storeChannel } +func (s SqlChannelStore) GetTeamChannels(teamId string) StoreChannel { + storeChannel := make(StoreChannel, 1) + + go func() { + result := 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}) + + if err != nil { + result.Err = model.NewLocAppError("SqlChannelStore.GetChannels", "store.sql_channel.get_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error()) + } else { + if len(*data) == 0 { + result.Err = model.NewLocAppError("SqlChannelStore.GetChannels", "store.sql_channel.get_channels.not_found.app_error", nil, "teamId="+teamId) + } else { + result.Data = data + } + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel { storeChannel := make(StoreChannel, 1) diff --git a/store/store.go b/store/store.go index b3d87da38..83a077c10 100644 --- a/store/store.go +++ b/store/store.go @@ -92,6 +92,7 @@ type ChannelStore interface { GetChannels(teamId string, userId string) StoreChannel GetMoreChannels(teamId string, userId string) StoreChannel GetChannelCounts(teamId string, userId string) StoreChannel + GetTeamChannels(teamId string) StoreChannel GetAll(teamId string) StoreChannel GetForPost(postId string) StoreChannel SaveMember(member *model.ChannelMember) StoreChannel -- cgit v1.2.3-1-g7c22