PLT-7077: ignore null array items in slack attachments (#6904)
* ignore null array items in incoming webhooks / command responses * consolidate code, process announcements in command response as well * make a bit more idiomatic, add tests * add missing file
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
83d53ea98c
Коммит
9ee7f661c7
@@ -230,3 +230,17 @@ func TestIncomingWebhookRequestFromJson(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIncomingWebhookNullArrayItems(t *testing.T) {
|
||||
payload := `{"attachments":[{"fields":[{"title":"foo","value":"bar","short":true}, null]}, null]}`
|
||||
iwr := IncomingWebhookRequestFromJson(strings.NewReader(payload))
|
||||
if iwr == nil {
|
||||
t.Fatal("IncomingWebhookRequest should not be nil")
|
||||
}
|
||||
if len(iwr.Attachments) != 1 {
|
||||
t.Fatalf("expected one attachment")
|
||||
}
|
||||
if len(iwr.Attachments[0].Fields) != 1 {
|
||||
t.Fatalf("expected one field")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user