mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-03-15 20:54:53 +00:00
parent
ca392c07ce
commit
9e578f6dfc
7 changed files with 61 additions and 1 deletions
|
@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Implement login link expiration (login links will now expire in 1 hour)
|
||||
- Add Gotify integration (#270)
|
||||
- Add API support for reading/writing the subject and subject_fail fields (#659)
|
||||
- Add "Disabled" priority for Pushover notifications (#663)
|
||||
|
||||
### Bug Fixes
|
||||
- Update hc.front.views.channels to handle empty strings in settings (#635)
|
||||
|
|
|
@ -66,7 +66,14 @@ CHANNEL_KINDS = (
|
|||
("gotify", "Gotify"),
|
||||
)
|
||||
|
||||
PO_PRIORITIES = {-2: "lowest", -1: "low", 0: "normal", 1: "high", 2: "emergency"}
|
||||
PO_PRIORITIES = {
|
||||
-3: "disabled",
|
||||
-2: "lowest",
|
||||
-1: "low",
|
||||
0: "normal",
|
||||
1: "high",
|
||||
2: "emergency",
|
||||
}
|
||||
|
||||
|
||||
def isostring(dt):
|
||||
|
|
|
@ -159,3 +159,19 @@ class NotifyPushoverTestCase(BaseTestCase):
|
|||
args, kwargs = mock_post.call_args
|
||||
payload = kwargs["data"]
|
||||
self.assertEqual(payload["title"], "Foo & Bar is DOWN")
|
||||
|
||||
@patch("hc.api.transports.requests.request")
|
||||
def test_it_handles_disabled_priority(self, mock_post):
|
||||
self._setup_data("123|-3")
|
||||
|
||||
self.channel.notify(self.check)
|
||||
self.assertEqual(Notification.objects.count(), 0)
|
||||
self.assertFalse(mock_post.called)
|
||||
|
||||
@patch("hc.api.transports.requests.request")
|
||||
def test_it_handles_disabled_up_priority(self, mock_post):
|
||||
self._setup_data("123|0|-3", status="up")
|
||||
|
||||
self.channel.notify(self.check)
|
||||
self.assertEqual(Notification.objects.count(), 0)
|
||||
self.assertFalse(mock_post.called)
|
||||
|
|
|
@ -476,6 +476,16 @@ class Pushover(HttpTransport):
|
|||
URL = "https://api.pushover.net/1/messages.json"
|
||||
CANCEL_TMPL = "https://api.pushover.net/1/receipts/cancel_by_tag/%s.json"
|
||||
|
||||
def is_noop(self, check) -> bool:
|
||||
pieces = self.channel.value.split("|")
|
||||
_, prio = pieces[0], pieces[1]
|
||||
|
||||
# The third element, if present, is the priority for "up" events
|
||||
if check.status == "up" and len(pieces) == 3:
|
||||
prio = pieces[2]
|
||||
|
||||
return int(prio) == -3
|
||||
|
||||
def notify(self, check, notification=None) -> None:
|
||||
pieces = self.channel.value.split("|")
|
||||
user_key, down_prio = pieces[0], pieces[1]
|
||||
|
|
|
@ -119,6 +119,7 @@ class AddOpsgenieForm(forms.Form):
|
|||
|
||||
|
||||
PRIO_CHOICES = [
|
||||
("-3", "Disabled"),
|
||||
("-2", "Lowest Priority"),
|
||||
("-1", "Low Priority"),
|
||||
("0", "Normal Priority"),
|
||||
|
|
|
@ -47,6 +47,21 @@ class AddPushoverTestCase(BaseTestCase):
|
|||
self.assertEqual(channel.value, "a|0|-1")
|
||||
self.assertEqual(channel.project, self.project)
|
||||
|
||||
def test_it_handles_prio_disabled(self):
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
|
||||
session = self.client.session
|
||||
session["pushover"] = "foo"
|
||||
session.save()
|
||||
|
||||
params = "?pushover_user_key=a&state=foo&prio=-3&prio_up=-3"
|
||||
r = self.client.get(self.url + params, follow=True)
|
||||
self.assertRedirects(r, self.channels_url)
|
||||
|
||||
channel = Channel.objects.get()
|
||||
self.assertEqual(channel.value, "a|-3|-3")
|
||||
self.assertEqual(channel.project, self.project)
|
||||
|
||||
def test_it_validates_priority(self):
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
<label class="col-sm-3 control-label">Priority for "down" events</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="po_priority" class="selectpicker form-control">
|
||||
<option
|
||||
value="-3"
|
||||
data-content="Disabled. <span class='help'>Does not notify about Down events.</span>">
|
||||
Disabled
|
||||
</option>
|
||||
<option
|
||||
value="-2"
|
||||
data-content="Lowest Priority. <span class='help'>Generates no notification on your device.</span>">
|
||||
|
@ -56,6 +61,11 @@
|
|||
<label class="col-sm-3 control-label">Priority for "up" events</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="po_priority_up" class="selectpicker form-control">
|
||||
<option
|
||||
value="-3"
|
||||
data-content="Disabled. <span class='help'>Does not notify about Up events.</span>">
|
||||
Disabled
|
||||
</option>
|
||||
<option
|
||||
value="-2"
|
||||
data-content="Lowest Priority. <span class='help'>Generates no notification on your device.</span>">
|
||||
|
|
Loading…
Reference in a new issue