Fixing error when proxy is not configured
@@ -37,9 +37,12 @@ class NotificationSlack(NotificationBase):
form = FormSlack
def _send(self, url, data):
+
+ proxy = self.config('proxies')
+ if proxy is not None and proxy != "":
proxies = {
- 'http': self.config('proxies'),
- 'https': self.config('proxies'),
+ 'http': proxy,
+ 'https': proxy,
}
if data['status'] == 'resolved':
@@ -51,11 +54,10 @@ class NotificationSlack(NotificationBase):
'text': message,
}
- if proxies is None:
- logger.info('Notifying Slack without proxy')
- util.post(url, json=json).raise_for_status()
- else:
+ if proxy is not None and proxy != "":
logger.info('Notifying Slack using proxy')
util.post(url, json=json, proxies=proxies).raise_for_status()
-
+ else:
+ logger.info('Notifying Slack without proxy')
+ util.post(url, json=json).raise_for_status()
\ No newline at end of file
