From 2acc99da55db2d197457756c4214b148e666f9df Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Wed, 8 Mar 2017 06:42:48 +0900 Subject: [PATCH 1/2] APIv4: GET /team/{team_id}/channels --- api4/channel.go | 22 ++++++++ api4/channel_test.go | 80 +++++++++++++++++++++++++++++ app/channel.go | 8 +++ i18n/en.json | 4 ++ model/client4.go | 15 ++++++ store/sql_channel_store.go | 34 ++++++++++++ store/sql_channel_store_test.go | 91 +++++++++++++++++++++++++++++++++ store/store.go | 1 + 8 files changed, 255 insertions(+) diff --git a/api4/channel.go b/api4/channel.go index 8be5224841490..b68ef7af6357b 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -18,6 +18,8 @@ func InitChannel() { BaseRoutes.Channels.Handle("", ApiSessionRequired(createChannel)).Methods("POST") BaseRoutes.Channels.Handle("/direct", ApiSessionRequired(createDirectChannel)).Methods("POST") + BaseRoutes.Team.Handle("/channels", ApiSessionRequired(getPublicChannels)).Methods("GET") + BaseRoutes.Channel.Handle("", ApiSessionRequired(getChannel)).Methods("GET") BaseRoutes.ChannelByName.Handle("", ApiSessionRequired(getChannelByName)).Methods("GET") BaseRoutes.ChannelByNameForTeamName.Handle("", ApiSessionRequired(getChannelByNameForTeamName)).Methods("GET") @@ -115,6 +117,26 @@ func getChannel(c *Context, w http.ResponseWriter, r *http.Request) { } } +func getPublicChannels(c *Context, w http.ResponseWriter, r *http.Request) { + c.RequireTeamId() + if c.Err != nil { + return + } + + if !app.SessionHasPermissionToTeam(c.Session, c.Params.TeamId, model.PERMISSION_LIST_TEAM_CHANNELS) { + c.SetPermissionError(model.PERMISSION_LIST_TEAM_CHANNELS) + return + } + + if channels, err := app.GetPublicChannels(c.Params.TeamId, c.Params.Page, c.Params.PerPage); err != nil { + c.Err = err + return + } else { + w.Write([]byte(channels.ToJson())) + return + } +} + func getChannelByName(c *Context, w http.ResponseWriter, r *http.Request) { c.RequireTeamId().RequireChannelName() if c.Err != nil { diff --git a/api4/channel_test.go b/api4/channel_test.go index c8faf7aa16216..9f34c49e8ac08 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -254,6 +254,86 @@ func TestGetChannel(t *testing.T) { CheckNotFoundStatus(t, resp) } +func TestGetPublicChannels(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + team := th.BasicTeam + publicChannel1 := th.BasicChannel + publicChannel2 := th.BasicChannel2 + + channels, resp := Client.GetPublicChannels(team.Id, 0, 100, "") + CheckNoError(t, resp) + if len(*channels) != 4 { + t.Fatal("wrong length") + } + + for i, c := range *channels { + if c.Type != model.CHANNEL_OPEN { + t.Fatal("should include open channel only") + } + + // only check the created 2 public channels + if i < 2 && !(c.DisplayName == publicChannel1.DisplayName || c.DisplayName == publicChannel2.DisplayName) { + t.Logf("channel %v: %v", i, c.DisplayName) + t.Fatal("should match public channel display name only") + } + } + + privateChannel := th.CreatePrivateChannel() + channels, resp = Client.GetPublicChannels(team.Id, 0, 100, "") + CheckNoError(t, resp) + if len(*channels) != 4 { + t.Fatal("wrong length") + } + + for _, c := range *channels { + if c.Type != model.CHANNEL_OPEN { + t.Fatal("should not include private channel") + } + + if c.DisplayName == privateChannel.DisplayName { + t.Fatal("should not match private channel display name") + } + } + + channels, resp = Client.GetPublicChannels(team.Id, 0, 1, "") + CheckNoError(t, resp) + if len(*channels) != 1 { + t.Fatal("should be one channel per page") + } + + channels, resp = Client.GetPublicChannels(team.Id, 1, 1, "") + CheckNoError(t, resp) + if len(*channels) != 1 { + t.Fatal("should be one channel per page") + } + + channels, resp = Client.GetPublicChannels(team.Id, 10000, 100, "") + CheckNoError(t, resp) + if len(*channels) != 0 { + t.Fatal("should be no channel") + } + + _, resp = Client.GetPublicChannels("junk", 0, 100, "") + CheckBadRequestStatus(t, resp) + + _, resp = Client.GetPublicChannels(model.NewId(), 0, 100, "") + CheckForbiddenStatus(t, resp) + + Client.Logout() + _, resp = Client.GetPublicChannels(team.Id, 0, 100, "") + CheckUnauthorizedStatus(t, resp) + + user := th.CreateUser() + Client.Login(user.Email, user.Password) + _, resp = Client.GetPublicChannels(team.Id, 0, 100, "") + CheckForbiddenStatus(t, resp) + + _, resp = th.SystemAdminClient.GetPublicChannels(team.Id, 0, 100, "") + CheckNoError(t, resp) +} + func TestGetChannelByName(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() diff --git a/app/channel.go b/app/channel.go index f037e64c388f6..9d604af124742 100644 --- a/app/channel.go +++ b/app/channel.go @@ -646,6 +646,14 @@ func GetChannelsUserNotIn(teamId string, userId string, offset int, limit int) ( } } +func GetPublicChannels(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) { + if result := <-Srv.Store.Channel().GetPublicChannels(teamId, offset, limit); result.Err != nil { + return nil, result.Err + } else { + return result.Data.(*model.ChannelList), nil + } +} + func GetChannelMember(channelId string, userId string) (*model.ChannelMember, *model.AppError) { if result := <-Srv.Store.Channel().GetMember(channelId, userId); result.Err != nil { return nil, result.Err diff --git a/i18n/en.json b/i18n/en.json index c013459e29662..d9558569b1d37 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -4699,6 +4699,10 @@ "id": "store.sql_channel.get_more_channels.get.app_error", "translation": "We couldn't get the channels" }, + { + "id": "store.sql_channel.get_public_channels.get.app_error", + "translation": "We couldn't get public channels" + }, { "id": "store.sql_channel.increment_mention_count.app_error", "translation": "We couldn't increment the mention count" diff --git a/model/client4.go b/model/client4.go index 34176bfb3b583..43fb9a270b018 100644 --- a/model/client4.go +++ b/model/client4.go @@ -98,6 +98,10 @@ func (c *Client4) GetChannelsRoute() string { return fmt.Sprintf("/channels") } +func (c *Client4) GetPublicChannelsRoute(teamId string) string { + return fmt.Sprintf(c.GetTeamRoute(teamId) + "/channels") +} + func (c *Client4) GetChannelRoute(channelId string) string { return fmt.Sprintf(c.GetChannelsRoute()+"/%v", channelId) } @@ -698,6 +702,17 @@ func (c *Client4) GetChannel(channelId, etag string) (*Channel, *Response) { } } +// GetPublicChannels returns a channel based on the provided team id string. +func (c *Client4) GetPublicChannels(teamId string, page int, perPage int, etag string) (*ChannelList, *Response) { + query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) + if r, err := c.DoApiGet(c.GetPublicChannelsRoute(teamId)+query, etag); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return ChannelListFromJson(r.Body), BuildResponse(r) + } +} + // GetChannelByName returns a channel based on the provided channel name and team id strings. func (c *Client4) GetChannelByName(channelName, teamId string, etag string) (*Channel, *Response) { if r, err := c.DoApiGet(c.GetChannelByNameRoute(channelName, teamId), etag); err != nil { diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index ff1716957d5e6..f8c2dad080e32 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -524,6 +524,40 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset in return storeChannel } +func (s SqlChannelStore) GetPublicChannels(teamId string, offset int, limit int) 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 IN ('O') + AND DeleteAt = 0 + ORDER BY DisplayName + LIMIT :Limit + OFFSET :Offset`, + map[string]interface{}{"TeamId": teamId, "Limit": limit, "Offset": offset}) + + if err != nil { + result.Err = model.NewLocAppError("SqlChannelStore.GetPublicChannels", "store.sql_channel.get_public_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error()) + } else { + result.Data = data + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} + type channelIdWithCountAndUpdateAt struct { Id string TotalMsgCount int64 diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go index df9c76905ee05..f2ee9ba618ebd 100644 --- a/store/sql_channel_store_test.go +++ b/store/sql_channel_store_test.go @@ -775,6 +775,97 @@ func TestChannelStoreGetMoreChannels(t *testing.T) { } } +func TestChannelStoreGetPublicChannels(t *testing.T) { + Setup() + + o1 := model.Channel{} + o1.TeamId = model.NewId() + o1.DisplayName = "OpenChannel1Team1" + o1.Name = "a" + model.NewId() + "b" + o1.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&o1)) + + o2 := model.Channel{} + o2.TeamId = model.NewId() + o2.DisplayName = "OpenChannel1Team2" + o2.Name = "a" + model.NewId() + "b" + o2.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&o2)) + + m3 := model.ChannelMember{} + m3.ChannelId = o2.Id + m3.UserId = model.NewId() + m3.NotifyProps = model.GetDefaultChannelNotifyProps() + Must(store.Channel().SaveMember(&m3)) + + o3 := model.Channel{} + o3.TeamId = o1.TeamId + o3.DisplayName = "PrivateChannel1Team1" + o3.Name = "a" + model.NewId() + "b" + o3.Type = model.CHANNEL_PRIVATE + Must(store.Channel().Save(&o3)) + + cresult := <-store.Channel().GetPublicChannels(o1.TeamId, 0, 100) + if cresult.Err != nil { + t.Fatal(cresult.Err) + } + list := cresult.Data.(*model.ChannelList) + + if len(*list) != 1 { + t.Fatal("wrong list") + } + + if (*list)[0].Name != o1.Name { + t.Fatal("missing channel") + } + + o4 := model.Channel{} + o4.TeamId = o1.TeamId + o4.DisplayName = "OpenChannel2Team1" + o4.Name = "a" + model.NewId() + "b" + o4.Type = model.CHANNEL_OPEN + Must(store.Channel().Save(&o4)) + + cresult = <-store.Channel().GetPublicChannels(o1.TeamId, 0, 100) + list = cresult.Data.(*model.ChannelList) + + if len(*list) != 2 { + t.Fatal("wrong list length") + } + + cresult = <-store.Channel().GetPublicChannels(o1.TeamId, 0, 1) + list = cresult.Data.(*model.ChannelList) + + if len(*list) != 1 { + t.Fatal("wrong list length") + } + + cresult = <-store.Channel().GetPublicChannels(o1.TeamId, 1, 1) + list = cresult.Data.(*model.ChannelList) + + if len(*list) != 1 { + t.Fatal("wrong list length") + } + + if r1 := <-store.Channel().AnalyticsTypeCount(o1.TeamId, model.CHANNEL_OPEN); r1.Err != nil { + t.Fatal(r1.Err) + } else { + if r1.Data.(int64) != 2 { + t.Log(r1.Data) + t.Fatal("wrong value") + } + } + + if r1 := <-store.Channel().AnalyticsTypeCount(o1.TeamId, model.CHANNEL_PRIVATE); r1.Err != nil { + t.Fatal(r1.Err) + } else { + if r1.Data.(int64) != 1 { + t.Log(r1.Data) + t.Fatal("wrong value") + } + } +} + func TestChannelStoreGetChannelCounts(t *testing.T) { Setup() diff --git a/store/store.go b/store/store.go index 7aa903f6fa84b..91175118ec8c4 100644 --- a/store/store.go +++ b/store/store.go @@ -101,6 +101,7 @@ type ChannelStore interface { GetDeletedByName(team_id string, name string) StoreChannel GetChannels(teamId string, userId string) StoreChannel GetMoreChannels(teamId string, userId string, offset int, limit int) StoreChannel + GetPublicChannels(teamId string, offset int, limit int) StoreChannel GetChannelCounts(teamId string, userId string) StoreChannel GetTeamChannels(teamId string) StoreChannel GetAll(teamId string) StoreChannel From 65551ff3b24d5c0411e6c8ef7ac4ade27985011e Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Thu, 9 Mar 2017 09:44:39 +0900 Subject: [PATCH 2/2] renamed function to G(g)etPublicChannelsForTeam --- api4/channel.go | 6 +++--- api4/channel_test.go | 22 +++++++++++----------- app/channel.go | 4 ++-- model/client4.go | 8 ++++---- store/sql_channel_store.go | 6 +++--- store/sql_channel_store_test.go | 16 +++++----------- store/store.go | 2 +- 7 files changed, 29 insertions(+), 35 deletions(-) diff --git a/api4/channel.go b/api4/channel.go index b68ef7af6357b..d86e540396f61 100644 --- a/api4/channel.go +++ b/api4/channel.go @@ -18,7 +18,7 @@ func InitChannel() { BaseRoutes.Channels.Handle("", ApiSessionRequired(createChannel)).Methods("POST") BaseRoutes.Channels.Handle("/direct", ApiSessionRequired(createDirectChannel)).Methods("POST") - BaseRoutes.Team.Handle("/channels", ApiSessionRequired(getPublicChannels)).Methods("GET") + BaseRoutes.Team.Handle("/channels", ApiSessionRequired(getPublicChannelsForTeam)).Methods("GET") BaseRoutes.Channel.Handle("", ApiSessionRequired(getChannel)).Methods("GET") BaseRoutes.ChannelByName.Handle("", ApiSessionRequired(getChannelByName)).Methods("GET") @@ -117,7 +117,7 @@ func getChannel(c *Context, w http.ResponseWriter, r *http.Request) { } } -func getPublicChannels(c *Context, w http.ResponseWriter, r *http.Request) { +func getPublicChannelsForTeam(c *Context, w http.ResponseWriter, r *http.Request) { c.RequireTeamId() if c.Err != nil { return @@ -128,7 +128,7 @@ func getPublicChannels(c *Context, w http.ResponseWriter, r *http.Request) { return } - if channels, err := app.GetPublicChannels(c.Params.TeamId, c.Params.Page, c.Params.PerPage); err != nil { + if channels, err := app.GetPublicChannelsForTeam(c.Params.TeamId, c.Params.Page, c.Params.PerPage); err != nil { c.Err = err return } else { diff --git a/api4/channel_test.go b/api4/channel_test.go index 9f34c49e8ac08..a7dbb958b1921 100644 --- a/api4/channel_test.go +++ b/api4/channel_test.go @@ -254,7 +254,7 @@ func TestGetChannel(t *testing.T) { CheckNotFoundStatus(t, resp) } -func TestGetPublicChannels(t *testing.T) { +func TestGetPublicChannelsForTeam(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() Client := th.Client @@ -262,7 +262,7 @@ func TestGetPublicChannels(t *testing.T) { publicChannel1 := th.BasicChannel publicChannel2 := th.BasicChannel2 - channels, resp := Client.GetPublicChannels(team.Id, 0, 100, "") + channels, resp := Client.GetPublicChannelsForTeam(team.Id, 0, 100, "") CheckNoError(t, resp) if len(*channels) != 4 { t.Fatal("wrong length") @@ -281,7 +281,7 @@ func TestGetPublicChannels(t *testing.T) { } privateChannel := th.CreatePrivateChannel() - channels, resp = Client.GetPublicChannels(team.Id, 0, 100, "") + channels, resp = Client.GetPublicChannelsForTeam(team.Id, 0, 100, "") CheckNoError(t, resp) if len(*channels) != 4 { t.Fatal("wrong length") @@ -297,40 +297,40 @@ func TestGetPublicChannels(t *testing.T) { } } - channels, resp = Client.GetPublicChannels(team.Id, 0, 1, "") + channels, resp = Client.GetPublicChannelsForTeam(team.Id, 0, 1, "") CheckNoError(t, resp) if len(*channels) != 1 { t.Fatal("should be one channel per page") } - channels, resp = Client.GetPublicChannels(team.Id, 1, 1, "") + channels, resp = Client.GetPublicChannelsForTeam(team.Id, 1, 1, "") CheckNoError(t, resp) if len(*channels) != 1 { t.Fatal("should be one channel per page") } - channels, resp = Client.GetPublicChannels(team.Id, 10000, 100, "") + channels, resp = Client.GetPublicChannelsForTeam(team.Id, 10000, 100, "") CheckNoError(t, resp) if len(*channels) != 0 { t.Fatal("should be no channel") } - _, resp = Client.GetPublicChannels("junk", 0, 100, "") + _, resp = Client.GetPublicChannelsForTeam("junk", 0, 100, "") CheckBadRequestStatus(t, resp) - _, resp = Client.GetPublicChannels(model.NewId(), 0, 100, "") + _, resp = Client.GetPublicChannelsForTeam(model.NewId(), 0, 100, "") CheckForbiddenStatus(t, resp) Client.Logout() - _, resp = Client.GetPublicChannels(team.Id, 0, 100, "") + _, resp = Client.GetPublicChannelsForTeam(team.Id, 0, 100, "") CheckUnauthorizedStatus(t, resp) user := th.CreateUser() Client.Login(user.Email, user.Password) - _, resp = Client.GetPublicChannels(team.Id, 0, 100, "") + _, resp = Client.GetPublicChannelsForTeam(team.Id, 0, 100, "") CheckForbiddenStatus(t, resp) - _, resp = th.SystemAdminClient.GetPublicChannels(team.Id, 0, 100, "") + _, resp = th.SystemAdminClient.GetPublicChannelsForTeam(team.Id, 0, 100, "") CheckNoError(t, resp) } diff --git a/app/channel.go b/app/channel.go index 9d604af124742..67caed94dd9a2 100644 --- a/app/channel.go +++ b/app/channel.go @@ -646,8 +646,8 @@ func GetChannelsUserNotIn(teamId string, userId string, offset int, limit int) ( } } -func GetPublicChannels(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) { - if result := <-Srv.Store.Channel().GetPublicChannels(teamId, offset, limit); result.Err != nil { +func GetPublicChannelsForTeam(teamId string, offset int, limit int) (*model.ChannelList, *model.AppError) { + if result := <-Srv.Store.Channel().GetPublicChannelsForTeam(teamId, offset, limit); result.Err != nil { return nil, result.Err } else { return result.Data.(*model.ChannelList), nil diff --git a/model/client4.go b/model/client4.go index 43fb9a270b018..13ddd1d78e36f 100644 --- a/model/client4.go +++ b/model/client4.go @@ -98,7 +98,7 @@ func (c *Client4) GetChannelsRoute() string { return fmt.Sprintf("/channels") } -func (c *Client4) GetPublicChannelsRoute(teamId string) string { +func (c *Client4) GetPublicChannelsForTeamRoute(teamId string) string { return fmt.Sprintf(c.GetTeamRoute(teamId) + "/channels") } @@ -702,10 +702,10 @@ func (c *Client4) GetChannel(channelId, etag string) (*Channel, *Response) { } } -// GetPublicChannels returns a channel based on the provided team id string. -func (c *Client4) GetPublicChannels(teamId string, page int, perPage int, etag string) (*ChannelList, *Response) { +// GetPublicChannelsForTeam returns a channel based on the provided team id string. +func (c *Client4) GetPublicChannelsForTeam(teamId string, page int, perPage int, etag string) (*ChannelList, *Response) { query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) - if r, err := c.DoApiGet(c.GetPublicChannelsRoute(teamId)+query, etag); err != nil { + if r, err := c.DoApiGet(c.GetPublicChannelsForTeamRoute(teamId)+query, etag); err != nil { return nil, &Response{StatusCode: r.StatusCode, Error: err} } else { defer closeBody(r) diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index f8c2dad080e32..338fab031e5b1 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -524,7 +524,7 @@ func (s SqlChannelStore) GetMoreChannels(teamId string, userId string, offset in return storeChannel } -func (s SqlChannelStore) GetPublicChannels(teamId string, offset int, limit int) StoreChannel { +func (s SqlChannelStore) GetPublicChannelsForTeam(teamId string, offset int, limit int) StoreChannel { storeChannel := make(StoreChannel, 1) go func() { @@ -538,7 +538,7 @@ func (s SqlChannelStore) GetPublicChannels(teamId string, offset int, limit int) Channels WHERE TeamId = :TeamId - AND Type IN ('O') + AND Type = 'O' AND DeleteAt = 0 ORDER BY DisplayName LIMIT :Limit @@ -546,7 +546,7 @@ func (s SqlChannelStore) GetPublicChannels(teamId string, offset int, limit int) map[string]interface{}{"TeamId": teamId, "Limit": limit, "Offset": offset}) if err != nil { - result.Err = model.NewLocAppError("SqlChannelStore.GetPublicChannels", "store.sql_channel.get_public_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error()) + result.Err = model.NewLocAppError("SqlChannelStore.GetPublicChannelsForTeam", "store.sql_channel.get_public_channels.get.app_error", nil, "teamId="+teamId+", err="+err.Error()) } else { result.Data = data } diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go index f2ee9ba618ebd..755bb76a68022 100644 --- a/store/sql_channel_store_test.go +++ b/store/sql_channel_store_test.go @@ -775,7 +775,7 @@ func TestChannelStoreGetMoreChannels(t *testing.T) { } } -func TestChannelStoreGetPublicChannels(t *testing.T) { +func TestChannelStoreGetPublicChannelsForTeam(t *testing.T) { Setup() o1 := model.Channel{} @@ -792,12 +792,6 @@ func TestChannelStoreGetPublicChannels(t *testing.T) { o2.Type = model.CHANNEL_OPEN Must(store.Channel().Save(&o2)) - m3 := model.ChannelMember{} - m3.ChannelId = o2.Id - m3.UserId = model.NewId() - m3.NotifyProps = model.GetDefaultChannelNotifyProps() - Must(store.Channel().SaveMember(&m3)) - o3 := model.Channel{} o3.TeamId = o1.TeamId o3.DisplayName = "PrivateChannel1Team1" @@ -805,7 +799,7 @@ func TestChannelStoreGetPublicChannels(t *testing.T) { o3.Type = model.CHANNEL_PRIVATE Must(store.Channel().Save(&o3)) - cresult := <-store.Channel().GetPublicChannels(o1.TeamId, 0, 100) + cresult := <-store.Channel().GetPublicChannelsForTeam(o1.TeamId, 0, 100) if cresult.Err != nil { t.Fatal(cresult.Err) } @@ -826,21 +820,21 @@ func TestChannelStoreGetPublicChannels(t *testing.T) { o4.Type = model.CHANNEL_OPEN Must(store.Channel().Save(&o4)) - cresult = <-store.Channel().GetPublicChannels(o1.TeamId, 0, 100) + cresult = <-store.Channel().GetPublicChannelsForTeam(o1.TeamId, 0, 100) list = cresult.Data.(*model.ChannelList) if len(*list) != 2 { t.Fatal("wrong list length") } - cresult = <-store.Channel().GetPublicChannels(o1.TeamId, 0, 1) + cresult = <-store.Channel().GetPublicChannelsForTeam(o1.TeamId, 0, 1) list = cresult.Data.(*model.ChannelList) if len(*list) != 1 { t.Fatal("wrong list length") } - cresult = <-store.Channel().GetPublicChannels(o1.TeamId, 1, 1) + cresult = <-store.Channel().GetPublicChannelsForTeam(o1.TeamId, 1, 1) list = cresult.Data.(*model.ChannelList) if len(*list) != 1 { diff --git a/store/store.go b/store/store.go index 91175118ec8c4..7c56b1c94db83 100644 --- a/store/store.go +++ b/store/store.go @@ -101,7 +101,7 @@ type ChannelStore interface { GetDeletedByName(team_id string, name string) StoreChannel GetChannels(teamId string, userId string) StoreChannel GetMoreChannels(teamId string, userId string, offset int, limit int) StoreChannel - GetPublicChannels(teamId string, offset int, limit int) StoreChannel + GetPublicChannelsForTeam(teamId string, offset int, limit int) StoreChannel GetChannelCounts(teamId string, userId string) StoreChannel GetTeamChannels(teamId string) StoreChannel GetAll(teamId string) StoreChannel