Change message for text so webhook works on slack (#2838)

* Change message for text so webhook works on slack

* Update preview text for the webhook in the FE
This commit is contained in:
Tomas Touceda 2021-11-08 15:13:02 -03:00 committed by GitHub
parent bb187a7885
commit d0777ccfd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 3 deletions

View File

@ -0,0 +1 @@
* Update key text for webhook from message to text to support Slack out of the box

View File

@ -250,7 +250,7 @@ class AppConfigForm extends Component {
}
const json = {
message:
text:
"More than X% of your hosts have not checked into Fleet for more than Y days. Youve been sent this message because the Host status webhook is enabled in your Fleet instance.",
data: {
unseen_hosts: 1,

View File

@ -38,7 +38,7 @@ func TriggerHostStatusWebhook(
percentUnseen, appConfig.WebhookSettings.HostStatusWebhook.DaysCount,
)
payload := map[string]interface{}{
"message": message,
"text": message,
"data": map[string]interface{}{
"unseen_hosts": unseen,
"total_hosts": total,

View File

@ -45,7 +45,7 @@ func TestTriggerHostStatusWebhook(t *testing.T) {
require.NoError(t, TriggerHostStatusWebhook(context.Background(), ds, kitlog.NewNopLogger(), ac))
assert.Equal(
t,
`{"data":{"days_unseen":2,"total_hosts":10,"unseen_hosts":6},"message":"More than 60.00% of your hosts have not checked into Fleet for more than 2 days. Youve been sent this message because the Host status webhook is enabled in your Fleet instance."}`,
`{"data":{"days_unseen":2,"total_hosts":10,"unseen_hosts":6},"text":"More than 60.00% of your hosts have not checked into Fleet for more than 2 days. Youve been sent this message because the Host status webhook is enabled in your Fleet instance."}`,
requestBody,
)
requestBody = ""