PLT-7212: fix missing webhook post attachments (#7011)
* fix missing webhook post attachments * make ProcessSlackAttachments return a new slice instead of modifying it
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
dc884983e6
Коммит
df1ff4ec97
47
app/webhook_test.go
Обычный файл
47
app/webhook_test.go
Обычный файл
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
)
|
||||
|
||||
func TestCreateWebhookPost(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer TearDown()
|
||||
|
||||
enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
|
||||
defer func() {
|
||||
utils.Cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
}()
|
||||
utils.Cfg.ServiceSettings.EnableIncomingWebhooks = true
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
hook, err := CreateIncomingWebhookForChannel(th.BasicUser.Id, th.BasicChannel, &model.IncomingWebhook{ChannelId: th.BasicChannel.Id})
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
defer DeleteIncomingWebhook(hook.Id)
|
||||
|
||||
post, err := CreateWebhookPost(hook.UserId, hook.TeamId, th.BasicChannel.Id, "foo", "user", "http://iconurl", model.StringInterface{
|
||||
"attachments": []*model.SlackAttachment{
|
||||
&model.SlackAttachment{
|
||||
Text: "text",
|
||||
},
|
||||
},
|
||||
}, model.POST_SLACK_ATTACHMENT)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
|
||||
for _, k := range []string{"from_webhook", "attachments"} {
|
||||
if _, ok := post.Props[k]; !ok {
|
||||
t.Fatal(k)
|
||||
}
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user