[MM-51090] - Notify Admin post fails plugin hook (#22508)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9252fff4d6
Коммит
a14958096d
@@ -6,6 +6,7 @@ package model
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -777,6 +778,9 @@ func (o *Post) ToNilIfInvalid() *Post {
|
|||||||
func (o *Post) ForPlugin() *Post {
|
func (o *Post) ForPlugin() *Post {
|
||||||
p := o.Clone()
|
p := o.Clone()
|
||||||
p.Metadata = nil
|
p.Metadata = nil
|
||||||
|
if p.Type == fmt.Sprintf("%sup_notification", PostCustomTypePrefix) {
|
||||||
|
p.DelProp("requested_features")
|
||||||
|
}
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -906,3 +907,34 @@ func TestPostAttachments(t *testing.T) {
|
|||||||
assert.Equal(t, attachments[0].Fields[1].Value, ":emoji2:")
|
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"))
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user