Browse Source

Pushover API expects form-data instead of JSON

pull/40/head
Pēteris Caune 9 years ago
parent
commit
24c111738a
2 changed files with 14 additions and 2 deletions
  1. +1
    -1
      hc/api/tests/test_notify.py
  2. +13
    -1
      hc/api/transports.py

+ 1
- 1
hc/api/tests/test_notify.py View File

@ -150,5 +150,5 @@ class NotifyTestCase(BaseTestCase):
assert Notification.objects.count() == 1
args, kwargs = mock_post.call_args
json = kwargs["json"]
json = kwargs["data"]
self.assertIn("DOWN", json["title"])

+ 13
- 1
hc/api/transports.py View File

@ -124,9 +124,21 @@ class PagerDuty(JsonTransport):
return self.post(self.URL, payload)
class Pushover(JsonTransport):
class Pushover(Transport):
URL = "https://api.pushover.net/1/messages.json"
def post(self, url, payload):
headers = {"User-Agent": "healthchecks.io"}
try:
r = requests.post(url, data=payload, timeout=5, headers=headers)
if r.status_code not in (200, 201, 204):
return "Received status code %d" % r.status_code
except requests.exceptions.Timeout:
# Well, we tried
return "Connection timed out"
except requests.exceptions.ConnectionError:
return "Connection failed"
def notify(self, check):
others = self.checks().filter(status="down").exclude(code=check.code)
ctx = {


Loading…
Cancel
Save