From 234958e0076655efd8a58ea4502edce3226418ed Mon Sep 17 00:00:00 2001 From: S4KH Date: Fri, 21 Oct 2016 20:36:13 +0800 Subject: HW 4139: Make channel limits configurable in the System Console (#4154) * Auto Changes * 4139 Made channel limits configurable in the System Console as described in the issue * Removed error message entries from other locales, made maxChannelsPerteam type to pointer * Added * symbol to maxChannelsPerTeam inside isValid function * Update team_test.go * Restored to old test * Checked maximum number channels per team when creating channel * Fixed code to pass api/channel_test.go * Reverted changes on config except MaxChannelsPerTeam * Update channel.go * Ran gofmt -w . * Reverted vendor directoy --- api/channel.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'api/channel.go') diff --git a/api/channel.go b/api/channel.go index 9cc8976c2..bae2a5277 100644 --- a/api/channel.go +++ b/api/channel.go @@ -73,6 +73,21 @@ func createChannel(c *Context, w http.ResponseWriter, r *http.Request) { return } + if channel.TeamId == c.TeamId { + + // Get total number of channels on current team + if result := <-Srv.Store.Channel().GetChannels(channel.TeamId, c.Session.UserId); result.Err != nil { + c.Err = model.NewLocAppError("createChannel", "api.channel.get_channels.error", nil, result.Err.Message) + return + } else { + data := result.Data.(*model.ChannelList) + if int64(len(data.Channels)+1) > *utils.Cfg.TeamSettings.MaxChannelsPerTeam { + c.Err = model.NewLocAppError("createChannel", "api.channel.create_channel.max_channel_limit.app_error", map[string]interface{}{"MaxChannelsPerTeam": *utils.Cfg.TeamSettings.MaxChannelsPerTeam}, "") + return + } + } + } + channel.CreatorId = c.Session.UserId if sc, err := CreateChannel(c, channel, true); err != nil { -- cgit v1.2.3-1-g7c22