mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Add "Disable SSL Verification" button to mattermost notification
This commit will add a button which will disable SSL notifications for the mattermost webhook. This is required when using self-signed certificates.
This commit is contained in:
@@ -14,16 +14,18 @@ logger = logging.getLogger('awx.main.notifications.mattermost_backend')
|
|||||||
|
|
||||||
class MattermostBackend(AWXBaseEmailBackend):
|
class MattermostBackend(AWXBaseEmailBackend):
|
||||||
|
|
||||||
init_parameters = {"mattermost_url": {"label": "Target URL", "type": "string"}}
|
init_parameters = {"mattermost_url": {"label": "Target URL", "type": "string"},
|
||||||
|
"mattermost_no_verify_ssl": {"label": "Verify SSL", "type": "bool"}}
|
||||||
recipient_parameter = "mattermost_url"
|
recipient_parameter = "mattermost_url"
|
||||||
sender_parameter = None
|
sender_parameter = None
|
||||||
|
|
||||||
def __init__(self, mattermost_channel=None, mattermost_username=None,
|
def __init__(self, mattermost_no_verify_ssl=False, mattermost_channel=None, mattermost_username=None,
|
||||||
mattermost_icon_url=None, fail_silently=False, **kwargs):
|
mattermost_icon_url=None, fail_silently=False, **kwargs):
|
||||||
super(MattermostBackend, self).__init__(fail_silently=fail_silently)
|
super(MattermostBackend, self).__init__(fail_silently=fail_silently)
|
||||||
self.mattermost_channel = mattermost_channel
|
self.mattermost_channel = mattermost_channel
|
||||||
self.mattermost_username = mattermost_username
|
self.mattermost_username = mattermost_username
|
||||||
self.mattermost_icon_url = mattermost_icon_url
|
self.mattermost_icon_url = mattermost_icon_url
|
||||||
|
self.mattermost_no_verify_ssl = mattermost_no_verify_ssl
|
||||||
|
|
||||||
def format_body(self, body):
|
def format_body(self, body):
|
||||||
return body
|
return body
|
||||||
@@ -41,7 +43,7 @@ class MattermostBackend(AWXBaseEmailBackend):
|
|||||||
payload['text'] = m.subject
|
payload['text'] = m.subject
|
||||||
|
|
||||||
r = requests.post("{}".format(m.recipients()[0]),
|
r = requests.post("{}".format(m.recipients()[0]),
|
||||||
data=json.dumps(payload))
|
data=json.dumps(payload), verify=(not self.mattermost_no_verify_ssl))
|
||||||
if r.status_code >= 400:
|
if r.status_code >= 400:
|
||||||
logger.error(smart_text(_("Error sending notification mattermost: {}").format(r.text)))
|
logger.error(smart_text(_("Error sending notification mattermost: {}").format(r.text)))
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
|
|||||||
@@ -365,6 +365,13 @@ export default ['i18n', function(i18n) {
|
|||||||
subForm: 'typeSubForm',
|
subForm: 'typeSubForm',
|
||||||
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
||||||
},
|
},
|
||||||
|
mattermost_no_verify_ssl: {
|
||||||
|
label: i18n._('Disable SSL Verification'),
|
||||||
|
type: 'checkbox',
|
||||||
|
ngShow: "notification_type.value == 'mattermost' ",
|
||||||
|
subForm: 'typeSubForm',
|
||||||
|
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
|
||||||
|
},
|
||||||
server: {
|
server: {
|
||||||
label: i18n._('IRC Server Address'),
|
label: i18n._('IRC Server Address'),
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
|||||||
Reference in New Issue
Block a user