summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/admin.go2
-rw-r--r--api/api.go2
-rw-r--r--api/channel.go23
-rw-r--r--api/channel_benchmark_test.go2
-rw-r--r--api/channel_test.go48
-rw-r--r--api/command.go2
-rw-r--r--api/context.go2
-rw-r--r--api/file.go2
-rw-r--r--api/import.go2
-rw-r--r--api/oauth.go2
-rw-r--r--api/post.go2
-rw-r--r--api/preference.go2
-rw-r--r--api/server.go2
-rw-r--r--api/slackimport.go2
-rw-r--r--api/team.go2
-rw-r--r--api/user.go2
-rw-r--r--api/web_conn.go2
-rw-r--r--api/web_hub.go2
-rw-r--r--api/web_socket.go2
-rw-r--r--api/web_team_hub.go2
-rw-r--r--api/webhook.go2
21 files changed, 80 insertions, 29 deletions
diff --git a/api/admin.go b/api/admin.go
index 8e0a03e4b..885a95d95 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -9,7 +9,7 @@ import (
"os"
"strings"
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
diff --git a/api/api.go b/api/api.go
index 6c7eda0a2..a6bb22982 100644
--- a/api/api.go
+++ b/api/api.go
@@ -5,7 +5,7 @@ package api
import (
"bytes"
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"html/template"
diff --git a/api/channel.go b/api/channel.go
index b85de3071..706baa004 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -4,14 +4,19 @@
package api
import (
- l4g "code.google.com/p/log4go"
"fmt"
+ l4g "github.com/alecthomas/log4go"
"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 {
diff --git a/api/channel_benchmark_test.go b/api/channel_benchmark_test.go
index fb8dd61bc..d6e1e5a55 100644
--- a/api/channel_benchmark_test.go
+++ b/api/channel_benchmark_test.go
@@ -189,7 +189,7 @@ func BenchmarkGetChannelExtraInfo(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := range channels {
- Client.Must(Client.GetChannelExtraInfo(channels[j].Id, ""))
+ Client.Must(Client.GetChannelExtraInfo(channels[j].Id, -1, ""))
}
}
}
diff --git a/api/channel_test.go b/api/channel_test.go
index 4ef164cba..117278378 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -674,7 +674,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
channel1 := &model.Channel{DisplayName: "A Test API Name", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
channel1 = Client.Must(Client.CreateChannel(channel1)).Data.(*model.Channel)
- rget := Client.Must(Client.GetChannelExtraInfo(channel1.Id, ""))
+ rget := Client.Must(Client.GetChannelExtraInfo(channel1.Id, -1, ""))
data := rget.Data.(*model.ChannelExtra)
if data.Id != channel1.Id {
t.Fatal("couldnt't get extra info")
@@ -690,7 +690,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
currentEtag := rget.Etag
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) != nil {
t.Log(cache_result.Data)
@@ -708,7 +708,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
Client2.LoginByEmail(team.Name, user2.Email, "pwd")
Client2.Must(Client2.JoinChannel(channel1.Id))
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) == nil {
t.Log(cache_result.Data)
@@ -717,7 +717,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
currentEtag = cache_result.Etag
}
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) != nil {
t.Log(cache_result.Data)
@@ -728,7 +728,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
Client2.Must(Client2.LeaveChannel(channel1.Id))
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) == nil {
t.Log(cache_result.Data)
@@ -737,7 +737,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
currentEtag = cache_result.Etag
}
- if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, currentEtag); err != nil {
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, -1, currentEtag); err != nil {
t.Fatal(err)
} else if cache_result.Data.(*model.ChannelExtra) != nil {
t.Log(cache_result.Data)
@@ -745,6 +745,42 @@ func TestGetChannelExtraInfo(t *testing.T) {
} else {
currentEtag = cache_result.Etag
}
+
+ Client2.Must(Client2.JoinChannel(channel1.Id))
+
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, 2, currentEtag); err != nil {
+ t.Fatal(err)
+ } else if extra := cache_result.Data.(*model.ChannelExtra); extra == nil {
+ t.Fatal("response should not be empty")
+ } else if len(extra.Members) != 2 {
+ t.Fatal("should've returned 2 members")
+ } else if extra.MemberCount != 2 {
+ t.Fatal("should've returned member count of 2")
+ } else {
+ currentEtag = cache_result.Etag
+ }
+
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, 1, currentEtag); err != nil {
+ t.Fatal(err)
+ } else if extra := cache_result.Data.(*model.ChannelExtra); extra == nil {
+ t.Fatal("response should not be empty")
+ } else if len(extra.Members) != 1 {
+ t.Fatal("should've returned only 1 member")
+ } else if extra.MemberCount != 2 {
+ t.Fatal("should've returned member count of 2")
+ } else {
+ currentEtag = cache_result.Etag
+ }
+
+ if cache_result, err := Client.GetChannelExtraInfo(channel1.Id, 1, currentEtag); err != nil {
+ t.Fatal(err)
+ } else if cache_result.Data.(*model.ChannelExtra) != nil {
+ t.Log(cache_result.Data)
+ t.Fatal("response should be empty")
+ } else {
+ currentEtag = cache_result.Etag
+ }
+
}
func TestAddChannelMember(t *testing.T) {
diff --git a/api/command.go b/api/command.go
index db57f0bae..00293cf16 100644
--- a/api/command.go
+++ b/api/command.go
@@ -11,7 +11,7 @@ import (
"strings"
"time"
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
diff --git a/api/context.go b/api/context.go
index b39f03a7d..561884c14 100644
--- a/api/context.go
+++ b/api/context.go
@@ -11,7 +11,7 @@ import (
"strconv"
"strings"
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
diff --git a/api/file.go b/api/file.go
index 67ebc14b7..d023515af 100644
--- a/api/file.go
+++ b/api/file.go
@@ -5,8 +5,8 @@ package api
import (
"bytes"
- l4g "code.google.com/p/log4go"
"fmt"
+ l4g "github.com/alecthomas/log4go"
"github.com/disintegration/imaging"
"github.com/goamz/goamz/aws"
"github.com/goamz/goamz/s3"
diff --git a/api/import.go b/api/import.go
index 81de78975..5c8f99348 100644
--- a/api/import.go
+++ b/api/import.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
)
diff --git a/api/oauth.go b/api/oauth.go
index 5753db8bd..eb5e0e496 100644
--- a/api/oauth.go
+++ b/api/oauth.go
@@ -4,8 +4,8 @@
package api
import (
- l4g "code.google.com/p/log4go"
"fmt"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
diff --git a/api/post.go b/api/post.go
index 958479427..be1ecd96a 100644
--- a/api/post.go
+++ b/api/post.go
@@ -4,8 +4,8 @@
package api
import (
- l4g "code.google.com/p/log4go"
"fmt"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
diff --git a/api/preference.go b/api/preference.go
index e9c74aafe..f5c96f1dd 100644
--- a/api/preference.go
+++ b/api/preference.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
"net/http"
diff --git a/api/server.go b/api/server.go
index 2bab62fac..33428009f 100644
--- a/api/server.go
+++ b/api/server.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/braintree/manners"
"github.com/gorilla/mux"
"github.com/mattermost/platform/store"
diff --git a/api/slackimport.go b/api/slackimport.go
index cab4c6184..e0a0ff036 100644
--- a/api/slackimport.go
+++ b/api/slackimport.go
@@ -6,8 +6,8 @@ package api
import (
"archive/zip"
"bytes"
- l4g "code.google.com/p/log4go"
"encoding/json"
+ l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
"io"
"mime/multipart"
diff --git a/api/team.go b/api/team.go
index fbcb301a9..e2dd8807e 100644
--- a/api/team.go
+++ b/api/team.go
@@ -5,8 +5,8 @@ package api
import (
"bytes"
- l4g "code.google.com/p/log4go"
"fmt"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
diff --git a/api/user.go b/api/user.go
index d4c7fcaf5..6c0ce86d6 100644
--- a/api/user.go
+++ b/api/user.go
@@ -5,9 +5,9 @@ package api
import (
"bytes"
- l4g "code.google.com/p/log4go"
b64 "encoding/base64"
"fmt"
+ l4g "github.com/alecthomas/log4go"
"github.com/disintegration/imaging"
"github.com/golang/freetype"
"github.com/gorilla/mux"
diff --git a/api/web_conn.go b/api/web_conn.go
index 50a003ace..2b0e29038 100644
--- a/api/web_conn.go
+++ b/api/web_conn.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/websocket"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
diff --git a/api/web_hub.go b/api/web_hub.go
index f80488824..4361d1035 100644
--- a/api/web_hub.go
+++ b/api/web_hub.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
)
diff --git a/api/web_socket.go b/api/web_socket.go
index 298e44b44..995e2a677 100644
--- a/api/web_socket.go
+++ b/api/web_socket.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"github.com/mattermost/platform/model"
diff --git a/api/web_team_hub.go b/api/web_team_hub.go
index 2c2386317..bb9ed9526 100644
--- a/api/web_team_hub.go
+++ b/api/web_team_hub.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
)
diff --git a/api/webhook.go b/api/webhook.go
index 34c308879..a9a88b7b8 100644
--- a/api/webhook.go
+++ b/api/webhook.go
@@ -4,7 +4,7 @@
package api
import (
- l4g "code.google.com/p/log4go"
+ l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"