mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-12 16:18:06 +00:00
Fix the ntfy integration to use Flip.new_status
This commit is contained in:
parent
462d4776d8
commit
4da32b9214
4 changed files with 14 additions and 11 deletions
|
@ -20,7 +20,9 @@ class NotifyNtfyTestCase(BaseTestCase):
|
|||
self.check.name = "Foo"
|
||||
self.check.tags = "foo bar"
|
||||
self.check.n_pings = 123
|
||||
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()
|
||||
|
||||
|
|
|
@ -1441,23 +1441,24 @@ class Ntfy(HttpTransport):
|
|||
def is_noop(self, status: str) -> bool:
|
||||
return self.priority(status) == 0
|
||||
|
||||
def notify(self, check: Check, notification: Notification) -> None:
|
||||
def notify_flip(self, flip: Flip, notification: Notification) -> None:
|
||||
ctx = {
|
||||
"check": check,
|
||||
"ping": self.last_ping(check),
|
||||
"down_checks": self.down_checks(check),
|
||||
"check": flip.owner,
|
||||
"status": flip.new_status,
|
||||
"ping": self.last_ping(flip.owner),
|
||||
"down_checks": self.down_checks(flip.owner),
|
||||
}
|
||||
payload = {
|
||||
"topic": self.channel.ntfy.topic,
|
||||
"priority": self.priority(check.status),
|
||||
"priority": self.priority(flip.new_status),
|
||||
"title": tmpl("ntfy_title.html", **ctx),
|
||||
"message": tmpl("ntfy_message.html", **ctx),
|
||||
"tags": ["red_circle" if check.status == "down" else "green_circle"],
|
||||
"tags": ["red_circle" if flip.new_status == "down" else "green_circle"],
|
||||
"actions": [
|
||||
{
|
||||
"action": "view",
|
||||
"label": f"View on {settings.SITE_NAME}",
|
||||
"url": check.cloaked_url(),
|
||||
"url": flip.owner.cloaked_url(),
|
||||
}
|
||||
],
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
{% line %}{% endline %}
|
||||
{% if down_checks %}
|
||||
{% if down_checks|length > 10 %}
|
||||
{% line %}{{ down_checks|length }} other checks are {% if check.status == "down" %}also{% else %}still{% endif %} down.{% endline %}
|
||||
{% line %}{{ down_checks|length }} other checks are {% if status == "down" %}also{% else %}still{% endif %} down.{% endline %}
|
||||
{% else %}
|
||||
{% line %}The following checks are {% if check.status == "down" %}also{% else %}still{% endif %} down:{% endline %}
|
||||
{% line %}The following checks are {% if status == "down" %}also{% else %}still{% endif %} down:{% endline %}
|
||||
{% for c in down_checks %}
|
||||
{% line %}• {{ c.name_then_code }} (last ping: {{ c.last_ping|naturaltime|default:"never" }}){% endline %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{{ check.name_then_code|safe }} is {{ check.status|upper }}
|
||||
{{ check.name_then_code|safe }} is {{ status|upper }}
|
||||
|
|
Loading…
Add table
Reference in a new issue