forked from GithubBackups/healthchecks
Pushover API expects form-data instead of JSON
This commit is contained in:
parent
a71ce64579
commit
24c111738a
@ -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"])
|
||||
|
@ -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…
x
Reference in New Issue
Block a user