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 /model/post_test.go | |
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 'model/post_test.go')
-rw-r--r-- | model/post_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/model/post_test.go b/model/post_test.go index ced84f26b..846c8c775 100644 --- a/model/post_test.go +++ b/model/post_test.go @@ -123,3 +123,46 @@ func TestPostIsSystemMessage(t *testing.T) { t.Fatalf("TestPostIsSystemMessage failed, expected post2.IsSystemMessage() to be true") } } + +func TestPostSanitizeProps(t *testing.T) { + post1 := &Post{ + Message: "test", + } + + post1.SanitizeProps() + + if post1.Props[PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("should be nil") + } + + post2 := &Post{ + Message: "test", + Props: StringInterface{ + PROPS_ADD_CHANNEL_MEMBER: "test", + }, + } + + post2.SanitizeProps() + + if post2.Props[PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("should be nil") + } + + post3 := &Post{ + Message: "test", + Props: StringInterface{ + PROPS_ADD_CHANNEL_MEMBER: "no good", + "attachments": "good", + }, + } + + post3.SanitizeProps() + + if post3.Props[PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("should be nil") + } + + if post3.Props["attachments"] == nil { + t.Fatal("should not be nil") + } +} |