From 18ee37586027e5672446a6f23c05a8ccb2b35896 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Sat, 21 Oct 2017 01:38:26 +0800 Subject: [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 --- model/post.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'model/post.go') diff --git a/model/post.go b/model/post.go index 523a97c73..a5ae0b82a 100644 --- a/model/post.go +++ b/model/post.go @@ -33,6 +33,7 @@ const ( POST_MESSAGE_MAX_RUNES = 4000 POST_PROPS_MAX_RUNES = 8000 POST_CUSTOM_TYPE_PREFIX = "custom_" + PROPS_ADD_CHANNEL_MEMBER = "add_channel_member" ) type Post struct { @@ -188,6 +189,18 @@ func (o *Post) IsValid() *AppError { return nil } +func (o *Post) SanitizeProps() { + membersToSanitize := []string{ + PROPS_ADD_CHANNEL_MEMBER, + } + + for _, member := range membersToSanitize { + if _, ok := o.Props[member]; ok { + delete(o.Props, member) + } + } +} + func (o *Post) PreSave() { if o.Id == "" { o.Id = NewId() -- cgit v1.2.3-1-g7c22