diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-01-11 06:54:55 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-01-11 06:54:55 -0500 |
commit | 7aa7f83524c06b6e0a9ec2274d4ac4744a83bda8 (patch) | |
tree | 55ae148c4336125f76f4aa9ba4731c94d9297811 /api/channel.go | |
parent | 2d141c29826f31aacad286b63cca61a551c619a8 (diff) | |
parent | d7230e8753c848725ba5b61d11b29b6280fce94b (diff) | |
download | chat-7aa7f83524c06b6e0a9ec2274d4ac4744a83bda8.tar.gz chat-7aa7f83524c06b6e0a9ec2274d4ac4744a83bda8.tar.bz2 chat-7aa7f83524c06b6e0a9ec2274d4ac4744a83bda8.zip |
Merge pull request #1824 from hmhealey/plt1525
PLT-1525 Fixed ChannelInviteModal displaying some users that are already in the channel
Diffstat (limited to 'api/channel.go')
-rw-r--r-- | api/channel.go | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/api/channel.go b/api/channel.go index b85de3071..674293e19 100644 --- a/api/channel.go +++ b/api/channel.go @@ -9,9 +9,14 @@ import ( "github.com/gorilla/mux" "github.com/mattermost/platform/model" "net/http" + "strconv" "strings" ) +const ( + defaultExtraMemberLimit = 100 +) + func InitChannel(r *mux.Router) { l4g.Debug("Initializing channel api routes") @@ -27,6 +32,7 @@ func InitChannel(r *mux.Router) { sr.Handle("/update_notify_props", ApiUserRequired(updateNotifyProps)).Methods("POST") sr.Handle("/{id:[A-Za-z0-9]+}/", ApiUserRequiredActivity(getChannel, false)).Methods("GET") sr.Handle("/{id:[A-Za-z0-9]+}/extra_info", ApiUserRequired(getChannelExtraInfo)).Methods("GET") + sr.Handle("/{id:[A-Za-z0-9]+}/extra_info/{member_limit:-?[0-9]+}", ApiUserRequired(getChannelExtraInfo)).Methods("GET") sr.Handle("/{id:[A-Za-z0-9]+}/join", ApiUserRequired(join)).Methods("POST") sr.Handle("/{id:[A-Za-z0-9]+}/leave", ApiUserRequired(leave)).Methods("POST") sr.Handle("/{id:[A-Za-z0-9]+}/delete", ApiUserRequired(deleteChannel)).Methods("POST") @@ -730,10 +736,19 @@ func getChannel(c *Context, w http.ResponseWriter, r *http.Request) { } func getChannelExtraInfo(c *Context, w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) id := params["id"] + var memberLimit int + if memberLimitString, ok := params["member_limit"]; !ok { + memberLimit = defaultExtraMemberLimit + } else if memberLimitInt64, err := strconv.ParseInt(memberLimitString, 10, 0); err != nil { + c.Err = model.NewAppError("getChannelExtraInfo", "Failed to parse member limit", err.Error()) + return + } else { + memberLimit = int(memberLimitInt64) + } + sc := Srv.Store.Channel().Get(id) var channel *model.Channel if cresult := <-sc; cresult.Err != nil { @@ -743,13 +758,13 @@ func getChannelExtraInfo(c *Context, w http.ResponseWriter, r *http.Request) { channel = cresult.Data.(*model.Channel) } - extraEtag := channel.ExtraEtag() + extraEtag := channel.ExtraEtag(memberLimit) if HandleEtag(extraEtag, w, r) { return } scm := Srv.Store.Channel().GetMember(id, c.Session.UserId) - ecm := Srv.Store.Channel().GetExtraMembers(id, 100) + ecm := Srv.Store.Channel().GetExtraMembers(id, memberLimit) ccm := Srv.Store.Channel().GetMemberCount(id) if cmresult := <-scm; cmresult.Err != nil { |