mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 17:51:06 -03:30
Set a user agent for the webhook if not provided
This commit is contained in:
@@ -8,6 +8,7 @@ import json
|
|||||||
from django.utils.encoding import smart_text
|
from django.utils.encoding import smart_text
|
||||||
|
|
||||||
from awx.main.notifications.base import TowerBaseEmailBackend
|
from awx.main.notifications.base import TowerBaseEmailBackend
|
||||||
|
from awx.main.utils import get_awx_version
|
||||||
|
|
||||||
logger = logging.getLogger('awx.main.notifications.webhook_backend')
|
logger = logging.getLogger('awx.main.notifications.webhook_backend')
|
||||||
|
|
||||||
@@ -27,6 +28,8 @@ class WebhookBackend(TowerBaseEmailBackend):
|
|||||||
|
|
||||||
def send_messages(self, messages):
|
def send_messages(self, messages):
|
||||||
sent_messages = 0
|
sent_messages = 0
|
||||||
|
if 'User-Agent' not in self.headers:
|
||||||
|
self.headers['User-Agent'] = "Tower {}".format(get_awx_version())
|
||||||
for m in messages:
|
for m in messages:
|
||||||
r = requests.post("{}".format(m.recipients()[0]),
|
r = requests.post("{}".format(m.recipients()[0]),
|
||||||
data=json.dumps(m.body),
|
data=json.dumps(m.body),
|
||||||
|
|||||||
Reference in New Issue
Block a user