summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2016-01-06 18:04:24 -0500
committerhmhealey <harrisonmhealey@gmail.com>2016-01-06 18:04:24 -0500
commit0e7a149982f73919badd9d366d06fa699925c89f (patch)
treeb8609b4ce5a962a3db80a790d4dcb1f48bf717c3 /api/channel.go
parent5855b5e4590889944e4a408f7185f84779fc701a (diff)
downloadchat-0e7a149982f73919badd9d366d06fa699925c89f.tar.gz
chat-0e7a149982f73919badd9d366d06fa699925c89f.tar.bz2
chat-0e7a149982f73919badd9d366d06fa699925c89f.zip
Added the ability to get more channel members from getChannelExtraInfo
Diffstat (limited to 'api/channel.go')
-rw-r--r--api/channel.go21
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 {