PLT-2188 Integrations: Support raw new lines in the text payload (#2993)
* Integrations: Support raw new lines in the text payload * Improve support for raw new lines in text payload The regexp used to escape control characters now also searches for additional fields: text|fallback|pretext|author_name|title|value
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
45527a9c1d
Коммит
5580c28e54
@@ -511,6 +511,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
t.Fatal("should have errored - webhooks turned off")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIncomingWebhooks(t *testing.T) {
|
||||
th := Setup().InitSystemAdmin()
|
||||
Client := th.SystemAdminClient
|
||||
@@ -529,11 +530,17 @@ func TestIncomingWebhooks(t *testing.T) {
|
||||
hook = Client.Must(Client.CreateIncomingWebhook(hook)).Data.(*model.IncomingWebhook)
|
||||
|
||||
url := "/hooks/" + hook.Id
|
||||
text := `this is a \"test\"
|
||||
that contains a newline and a tab`
|
||||
|
||||
if _, err := Client.DoPost(url, "{\"text\":\"this is a test\"}", "application/json"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := Client.DoPost(url, "{\"text\":\""+text+"\"}", "application/json"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := Client.DoPost(url, fmt.Sprintf("{\"text\":\"this is a test\", \"channel\":\"%s\"}", channel1.Name), "application/json"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -552,6 +559,10 @@ func TestIncomingWebhooks(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := Client.DoPost(url, "payload={\"text\":\""+text+"\"}", "application/x-www-form-urlencoded"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
attachmentPayload := `{
|
||||
"text": "this is a test",
|
||||
"attachments": [
|
||||
|
||||
Ссылка в новой задаче
Block a user