Skip to content

Commit

Permalink
Merge 4f7e933 into 71e6a42
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilander committed Mar 1, 2017
2 parents 71e6a42 + 4f7e933 commit c315fb8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 4 additions & 0 deletions api/channel.go
Expand Up @@ -739,6 +739,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
Expand Down
5 changes: 4 additions & 1 deletion api/channel_test.go
Expand Up @@ -863,7 +863,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) {
Expand Down Expand Up @@ -1963,6 +1962,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) {
Expand Down
11 changes: 11 additions & 0 deletions api4/channel_test.go
Expand Up @@ -4,6 +4,7 @@
package api4

import (
"fmt"
"net/http"
"strconv"
"testing"
Expand Down Expand Up @@ -504,6 +505,16 @@ func TestViewChannel(t *testing.T) {
_, resp = Client.ViewChannel(th.BasicUser2.Id, view)
CheckForbiddenStatus(t, resp)

if r, err := Client.DoApiPost(fmt.Sprintf("/channels/members/%v/view", th.BasicUser.Id), "garbage"); err == nil {
t.Fatal("should have errored")
} else {
if r.StatusCode != http.StatusBadRequest {
t.Log("actual: " + strconv.Itoa(r.StatusCode))
t.Log("expected: " + strconv.Itoa(http.StatusBadRequest))
t.Fatal("wrong status code")
}
}

Client.Logout()
_, resp = Client.ViewChannel(th.BasicUser.Id, view)
CheckUnauthorizedStatus(t, resp)
Expand Down
6 changes: 3 additions & 3 deletions webapp/stores/post_store.jsx
Expand Up @@ -99,11 +99,11 @@ class PostStoreClass extends EventEmitter {
return null;
}

const posts = postInfo.postList;
const postList = postInfo.postList;
let post = null;

if (posts.posts.hasOwnProperty(postId)) {
post = posts.posts[postId];
if (postList && postList.posts && postList.posts.hasOwnProperty(postId)) {
post = postList.posts[postId];
}

return post;
Expand Down

0 comments on commit c315fb8

Please sign in to comment.