diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-10-21 01:38:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 01:38:26 +0800 |
commit | 18ee37586027e5672446a6f23c05a8ccb2b35896 (patch) | |
tree | d915646e73a91b0082ecdf89b7a290291c0c9451 /api | |
parent | cbb18479e9a4c410664535f6e0f5032d4261dfff (diff) | |
download | chat-18ee37586027e5672446a6f23c05a8ccb2b35896.tar.gz chat-18ee37586027e5672446a6f23c05a8ccb2b35896.tar.bz2 chat-18ee37586027e5672446a6f23c05a8ccb2b35896.zip |
[PLT-7362] Option to add user to channel if mentioned user is not currently in the channel (#7619)
* Option to add user to channel if mentioned user is not currently in the channel
* instead of link from server, just add component on client side to add channel member
* change implementation using post.props
* do clean up and add test
* sanitize post.props['add_channel_member'] on post creation
* move sanitize to app.CreatePost and also apply to app.UpdatePost
Diffstat (limited to 'api')
-rw-r--r-- | api/post_test.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/api/post_test.go b/api/post_test.go index 8b5cbd454..901a7c6d0 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -39,7 +39,7 @@ func TestCreatePost(t *testing.T) { adminUser := th.CreateUser(th.SystemAdminClient) th.LinkUserToTeam(adminUser, adminTeam) - post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a"} + post1 := &model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a", Props: model.StringInterface{model.PROPS_ADD_CHANNEL_MEMBER: "no good"}} rpost1, err := Client.CreatePost(post1) if err != nil { t.Fatal(err) @@ -61,6 +61,10 @@ func TestCreatePost(t *testing.T) { t.Fatal("Newly craeted post shouldn't have EditAt set") } + if rpost1.Data.(*model.Post).Props[model.PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("newly created post shouldn't have Props['add_channel_member'] set") + } + _, err = Client.CreatePost(&model.Post{ChannelId: channel1.Id, Message: "#hashtag a" + model.NewId() + "a", Type: model.POST_SYSTEM_GENERIC}) if err == nil { t.Fatal("should have failed - bad post type") @@ -433,6 +437,7 @@ func TestUpdatePost(t *testing.T) { msg2 := "zz" + model.NewId() + " update post 1" rpost2.Data.(*model.Post).Message = msg2 + rpost2.Data.(*model.Post).Props[model.PROPS_ADD_CHANNEL_MEMBER] = "no good" if rupost2, err := Client.UpdatePost(rpost2.Data.(*model.Post)); err != nil { t.Fatal(err) } else { @@ -442,6 +447,9 @@ func TestUpdatePost(t *testing.T) { if rupost2.Data.(*model.Post).EditAt == 0 { t.Fatal("EditAt not updated for post") } + if rupost2.Data.(*model.Post).Props[model.PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("failed to sanitize Props['add_channel_member'], should be nil") + } } msg1 := "#hashtag a" + model.NewId() + " update post 2" |