Reshape webhook payload

1. Remove alert.title, alert.message, alert.image_url from webhook payload, they are deprecated.
2. Pass alert_group_id to webhook payload.
This commit is contained in:
Innokentii Konstantinov 2022-07-13 14:54:53 +04:00
parent 35a31701f6
commit cede946359
2 changed files with 2 additions and 5 deletions

View file

@ -118,11 +118,8 @@ class CustomButton(models.Model):
elif self.data:
rendered_data = Template(self.data).render(
{
"alert_title": self._escape_string(alert.title),
"alert_message": self._escape_string(alert.message),
"alert_url": alert.link_to_upstream_details,
"alert_payload": self._escape_alert_payload(alert.raw_request_data),
"alert_payload_json": json.dumps(alert.raw_request_data),
"alert_group_id": alert.group.public_primary_key,
}
)
post_kwargs["json"] = json.loads(rendered_data)

View file

@ -36,7 +36,7 @@ export const form: { name: string; fields: FormItem[] } = {
name: 'data',
getDisabled: (form_data) => Boolean(form_data.forward_whole_payload),
type: FormItemType.TextArea,
description: 'Available variables: {{ alert_title }}, {{ alert_message }}, {{ alert_url }}, {{ alert_payload }}',
description: 'Available variables: {{ alert_payload }}, {{ alert_group_id }}',
extra: {
rows: 9,
},