diff options
author | S4KH <kh.syerikjan@gmail.com> | 2016-10-21 20:36:13 +0800 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-10-21 08:36:13 -0400 |
commit | 234958e0076655efd8a58ea4502edce3226418ed (patch) | |
tree | 568c2e2f06a6921414e2cded9cb682651768aee8 /api | |
parent | d13ba8c55c981978f3b962c6991f478b36bf8a8b (diff) | |
download | chat-234958e0076655efd8a58ea4502edce3226418ed.tar.gz chat-234958e0076655efd8a58ea4502edce3226418ed.tar.bz2 chat-234958e0076655efd8a58ea4502edce3226418ed.zip |
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
Diffstat (limited to 'api')
-rw-r--r-- | api/channel.go | 15 |
1 files changed, 15 insertions, 0 deletions
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 { |