From e67549e4a1ebaf23d9994e75411670491087c44b Mon Sep 17 00:00:00 2001 From: Romain Brucker Date: Tue, 26 Sep 2017 11:32:05 -0500 Subject: [PATCH 1/4] Changing the color option for hipchat to always be lowercase (expected by the API) Signed-off-by: Romain Brucker --- awx/main/notifications/hipchat_backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/main/notifications/hipchat_backend.py b/awx/main/notifications/hipchat_backend.py index e75fcbc296..30e22ae07f 100644 --- a/awx/main/notifications/hipchat_backend.py +++ b/awx/main/notifications/hipchat_backend.py @@ -38,7 +38,7 @@ class HipChatBackend(AWXBaseEmailBackend): r = requests.post("{}/v2/room/{}/notification".format(self.api_url, rcp), params={"auth_token": self.token}, verify=False, - json={"color": self.color, + json={"color": self.color.lower(), "message": m.subject, "notify": self.notify, "from": m.from_email, From 1bb72cc68024995bca98925a5dc1709173c9c335 Mon Sep 17 00:00:00 2001 From: Romain Brucker Date: Thu, 28 Sep 2017 11:15:14 -0500 Subject: [PATCH 2/4] Adding a check to see if the color is 'None' before lowercasing it for @matburt --- awx/main/notifications/hipchat_backend.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/awx/main/notifications/hipchat_backend.py b/awx/main/notifications/hipchat_backend.py index 30e22ae07f..8997d74899 100644 --- a/awx/main/notifications/hipchat_backend.py +++ b/awx/main/notifications/hipchat_backend.py @@ -26,10 +26,13 @@ class HipChatBackend(AWXBaseEmailBackend): def __init__(self, token, color, api_url, notify, fail_silently=False, **kwargs): super(HipChatBackend, self).__init__(fail_silently=fail_silently) self.token = token - self.color = color + if color == 'None': + self.color = color + else: + self.color = color.lower() self.api_url = api_url self.notify = notify - + def send_messages(self, messages): sent_messages = 0 @@ -38,7 +41,7 @@ class HipChatBackend(AWXBaseEmailBackend): r = requests.post("{}/v2/room/{}/notification".format(self.api_url, rcp), params={"auth_token": self.token}, verify=False, - json={"color": self.color.lower(), + json={"color": self.color, "message": m.subject, "notify": self.notify, "from": m.from_email, From 31e559b6a172b1fc7ecfd501fabf952cc2bd4a0c Mon Sep 17 00:00:00 2001 From: Romain Brucker Date: Thu, 28 Sep 2017 11:33:45 -0500 Subject: [PATCH 3/4] Checking if color is not None before setting it to lowercase --- awx/main/notifications/hipchat_backend.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/awx/main/notifications/hipchat_backend.py b/awx/main/notifications/hipchat_backend.py index 8997d74899..cc5cbbe71a 100644 --- a/awx/main/notifications/hipchat_backend.py +++ b/awx/main/notifications/hipchat_backend.py @@ -26,9 +26,7 @@ class HipChatBackend(AWXBaseEmailBackend): def __init__(self, token, color, api_url, notify, fail_silently=False, **kwargs): super(HipChatBackend, self).__init__(fail_silently=fail_silently) self.token = token - if color == 'None': - self.color = color - else: + if color is not None: self.color = color.lower() self.api_url = api_url self.notify = notify From cdc60965155534ec045521a4cb5ec7dfd82302e3 Mon Sep 17 00:00:00 2001 From: Romain Brucker Date: Thu, 28 Sep 2017 11:37:07 -0500 Subject: [PATCH 4/4] fixing indent --- awx/main/notifications/hipchat_backend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/main/notifications/hipchat_backend.py b/awx/main/notifications/hipchat_backend.py index cc5cbbe71a..3d7505351b 100644 --- a/awx/main/notifications/hipchat_backend.py +++ b/awx/main/notifications/hipchat_backend.py @@ -26,11 +26,11 @@ class HipChatBackend(AWXBaseEmailBackend): def __init__(self, token, color, api_url, notify, fail_silently=False, **kwargs): super(HipChatBackend, self).__init__(fail_silently=fail_silently) self.token = token - if color is not None: - self.color = color.lower() + if color is not None: + self.color = color.lower() self.api_url = api_url self.notify = notify - + def send_messages(self, messages): sent_messages = 0