mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 18:20:00 -03:30
Use correct notif. bodies when sending test notifs
* Notification backends now handle body of notifications differently * .. depending on their type (webhook, email, and pagerduty) are currently the only three notification types that use body * email and pagerduty expect a string * webhooks expects a dict in string format
This commit is contained in:
@@ -4313,8 +4313,15 @@ class NotificationTemplateTest(GenericAPIView):
|
|||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
obj = self.get_object()
|
obj = self.get_object()
|
||||||
notification = obj.generate_notification("Tower Notification Test {} {}".format(obj.id, settings.TOWER_URL_BASE),
|
msg = "Tower Notification Test {} {}".format(obj.id, settings.TOWER_URL_BASE)
|
||||||
{"body": "Ansible Tower Test Notification {} {}".format(obj.id, settings.TOWER_URL_BASE)})
|
if obj.notification_type in ('email', 'pagerduty'):
|
||||||
|
body = "Ansible Tower Test Notification {} {}".format(obj.id, settings.TOWER_URL_BASE)
|
||||||
|
elif obj.notification_type == 'webhook':
|
||||||
|
body = '{{"body": "Ansible Tower Test Notification {} {}"}}'.format(obj.id, settings.TOWER_URL_BASE)
|
||||||
|
else:
|
||||||
|
body = {"body": "Ansible Tower Test Notification {} {}".format(obj.id, settings.TOWER_URL_BASE)}
|
||||||
|
notification = obj.generate_notification(msg, body)
|
||||||
|
|
||||||
if not notification:
|
if not notification:
|
||||||
return Response({}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user