From b0c2b1b9c8341a15c4988c41a25594768524651a Mon Sep 17 00:00:00 2001 From: pemontto Date: Mon, 27 Apr 2020 15:12:36 +0100 Subject: [PATCH] jira: Use display_url in output. --- zulip_bots/zulip_bots/bots/jira/jira.conf | 1 + zulip_bots/zulip_bots/bots/jira/jira.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/jira/jira.conf b/zulip_bots/zulip_bots/bots/jira/jira.conf index 86c2559..22e5eaf 100644 --- a/zulip_bots/zulip_bots/bots/jira/jira.conf +++ b/zulip_bots/zulip_bots/bots/jira/jira.conf @@ -2,3 +2,4 @@ username = password = domain = +# display_url = [optional] diff --git a/zulip_bots/zulip_bots/bots/jira/jira.py b/zulip_bots/zulip_bots/bots/jira/jira.py index 5d8b0e4..4dd165b 100644 --- a/zulip_bots/zulip_bots/bots/jira/jira.py +++ b/zulip_bots/zulip_bots/bots/jira/jira.py @@ -134,6 +134,11 @@ class JiraHandler: else: self.domain_with_protocol = 'https://' + domain + # Use the front facing URL in output + self.display_url = config.get('display_url') + if not self.display_url: + self.display_url = self.domain_with_protocol + def handle_message(self, message: Dict[str, str], bot_handler: Any) -> None: content = message.get('content') response = '' @@ -153,7 +158,7 @@ class JiraHandler: headers={'Authorization': self.auth}, ).json() - url = self.domain_with_protocol + '/browse/' + key + url = self.display_url + '/browse/' + key errors = jira_response.get('errorMessages', []) fields = jira_response.get('fields', {}) @@ -196,7 +201,7 @@ class JiraHandler: jira_response_json = jira_response.json() if jira_response.text else {} key = jira_response_json.get('key', '') - url = self.domain_with_protocol + '/browse/' + key + url = self.display_url + '/browse/' + key errors = list(jira_response_json.get('errors', {}).values()) if errors: response = 'Oh no! Jira raised an error:\n > ' + ', '.join(errors) @@ -220,7 +225,7 @@ class JiraHandler: jira_response_json = jira_response.json() if jira_response.text else {} - url = self.domain_with_protocol + '/browse/' + key + url = self.display_url + '/browse/' + key errors = list(jira_response_json.get('errors', {}).values()) if errors: response = 'Oh no! Jira raised an error:\n > ' + ', '.join(errors)