summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/channel.go4
-rw-r--r--api/channel_test.go5
2 files changed, 8 insertions, 1 deletions
diff --git a/api/channel.go b/api/channel.go
index 2604cc5ce..9c11f073e 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -772,6 +772,10 @@ func autocompleteChannels(c *Context, w http.ResponseWriter, r *http.Request) {
func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) {
view := model.ChannelViewFromJson(r.Body)
+ if view == nil {
+ c.SetInvalidParam("viewChannel", "channel_view")
+ return
+ }
if err := app.ViewChannel(view, c.Session.UserId, !c.Session.IsMobileApp()); err != nil {
c.Err = err
diff --git a/api/channel_test.go b/api/channel_test.go
index d8da3374b..93c79d416 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -903,7 +903,6 @@ func TestGetChannel(t *testing.T) {
if _, err := Client.GetChannels(""); err == nil {
t.Fatal("should have failed - wrong team id")
}
-
}
func TestGetMoreChannelsPage(t *testing.T) {
@@ -2003,6 +2002,10 @@ func TestViewChannel(t *testing.T) {
t.Log(rdata.Member.MsgCount)
t.Fatal("message counts don't match")
}
+
+ if _, err := Client.DoApiPost(Client.GetTeamRoute()+"/channels/view", "garbage"); err == nil {
+ t.Fatal("should have been an error")
+ }
}
func TestGetChannelMembersByIds(t *testing.T) {