mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-05 05:15:26 +00:00
Fix the Apprise integration to use Flip.new_status
This commit is contained in:
parent
a6b8f4c71e
commit
fe9bb0d1e5
4 changed files with 11 additions and 10 deletions
hc/api
templates/integrations
|
@ -27,7 +27,9 @@ class NotifyAppriseTestCase(BaseTestCase):
|
|||
|
||||
self.check = Check(project=self.project)
|
||||
self.check.name = "Foo"
|
||||
self.check.status = "down"
|
||||
# Transport classes should use flip.new_status,
|
||||
# so the status "paused" should not appear anywhere
|
||||
self.check.status = "paused"
|
||||
self.check.last_ping = now() - td(minutes=61)
|
||||
self.check.save()
|
||||
|
||||
|
|
|
@ -1088,21 +1088,20 @@ class Trello(HttpTransport):
|
|||
|
||||
|
||||
class Apprise(HttpTransport):
|
||||
def notify(self, check: Check, notification: Notification) -> None:
|
||||
def notify_flip(self, flip: Flip, notification: Notification) -> None:
|
||||
if not settings.APPRISE_ENABLED:
|
||||
# Not supported and/or enabled
|
||||
raise TransportError("Apprise is disabled and/or not installed")
|
||||
|
||||
a = apprise.Apprise()
|
||||
title = tmpl("apprise_title.html", check=check)
|
||||
body = tmpl("apprise_description.html", check=check)
|
||||
check, status = flip.owner, flip.new_status
|
||||
title = tmpl("apprise_title.html", check=check, status=status)
|
||||
body = tmpl("apprise_description.html", check=check, status=status)
|
||||
|
||||
a.add(self.channel.value)
|
||||
|
||||
notify_type = (
|
||||
apprise.NotifyType.SUCCESS
|
||||
if check.status == "up"
|
||||
else apprise.NotifyType.FAILURE
|
||||
apprise.NotifyType.SUCCESS if status == "up" else apprise.NotifyType.FAILURE
|
||||
)
|
||||
|
||||
if not a.notify(body=body, title=title, notify_type=notify_type):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% load humanize %}
|
||||
{{ check.name_then_code }} is {{ check.status|upper }}.
|
||||
{% if check.status == "down" and check.last_ping %}
|
||||
{{ check.name_then_code }} is {{ status|upper }}.
|
||||
{% if status == "down" and check.last_ping %}
|
||||
Last ping was {{ check.last_ping|naturaltime }}.
|
||||
{% endif %}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{{ check.name_then_code }} is {{ check.status|upper }}
|
||||
{{ check.name_then_code }} is {{ status|upper }}
|
||||
|
|
Loading…
Add table
Reference in a new issue