mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Use custom webhook bodies as is (instead of as a sub-field in webhook)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# Copyright (c) 2016 Ansible, Inc.
|
||||
# All Rights Reserved.
|
||||
|
||||
import json
|
||||
import logging
|
||||
import requests
|
||||
|
||||
@@ -37,6 +38,15 @@ class WebhookBackend(AWXBaseEmailBackend):
|
||||
super(WebhookBackend, self).__init__(fail_silently=fail_silently)
|
||||
|
||||
def format_body(self, body):
|
||||
# If `body` has body field, attempt to use this as the main body,
|
||||
# otherwise, leave it as a sub-field
|
||||
if isinstance(body, dict) and 'body' in body and isinstance(body['body'], str):
|
||||
try:
|
||||
potential_body = json.loads(body['body'])
|
||||
if isinstance(potential_body, dict):
|
||||
body = potential_body
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
return body
|
||||
|
||||
def send_messages(self, messages):
|
||||
|
||||
Reference in New Issue
Block a user