diff --git a/model/post.go b/model/post.go index 0cf604f032..45e47d2cac 100644 --- a/model/post.go +++ b/model/post.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "errors" + "fmt" "io" "net/http" "regexp" @@ -777,6 +778,9 @@ func (o *Post) ToNilIfInvalid() *Post { func (o *Post) ForPlugin() *Post { p := o.Clone() p.Metadata = nil + if p.Type == fmt.Sprintf("%sup_notification", PostCustomTypePrefix) { + p.DelProp("requested_features") + } return p } diff --git a/model/post_test.go b/model/post_test.go index e8894fd28c..b80a4a04c0 100644 --- a/model/post_test.go +++ b/model/post_test.go @@ -5,6 +5,7 @@ package model import ( "encoding/json" + "fmt" "os" "strings" "sync" @@ -906,3 +907,34 @@ func TestPostAttachments(t *testing.T) { assert.Equal(t, attachments[0].Fields[1].Value, ":emoji2:") }) } + +func TestPostForPlugin(t *testing.T) { + t.Run("post type custom_up_notification for plugin should have no requested features prop", func(t *testing.T) { + p := &Post{ + Type: fmt.Sprintf("%sup_notification", PostCustomTypePrefix), + } + props := make(StringInterface) + props["requested_features"] = "test_requested_features_map" + p.SetProps(props) + + require.NotNil(t, p.GetProp("requested_features")) + + pluginPost := p.ForPlugin() + require.Nil(t, pluginPost.GetProp("requested_features")) + }) + + t.Run("non post type custom_up_notification for plugin should have requested features prop", func(t *testing.T) { + p := &Post{ + Type: PostTypeWelcomePost, + } + props := make(StringInterface) + props["requested_features"] = "test_requested_features_map" + p.SetProps(props) + + require.NotNil(t, p.GetProp("requested_features")) + + pluginPost := p.ForPlugin() + require.NotNil(t, pluginPost.GetProp("requested_features")) + }) + +}