0
0
Fork 0
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:
Pēteris Caune 2024-04-12 14:17:12 +03:00
parent a6b8f4c71e
commit fe9bb0d1e5
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
4 changed files with 11 additions and 10 deletions

View file

@ -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()

View file

@ -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):

View file

@ -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 %}

View file

@ -1 +1 @@
{{ check.name_then_code }} is {{ check.status|upper }}
{{ check.name_then_code }} is {{ status|upper }}