0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-04 21:05:26 +00:00

Fix the Gotify integration to use Flip.new_status

This commit is contained in:
Pēteris Caune 2024-04-12 14:39:08 +03:00
parent 5b6dfb9101
commit 1aa068553d
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
4 changed files with 13 additions and 7 deletions

View file

@ -18,7 +18,9 @@ class NotifyGotidyTestCase(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

@ -1384,7 +1384,7 @@ class Signal(Transport):
class Gotify(HttpTransport):
def notify(self, check: Check, notification: Notification) -> None:
def notify_flip(self, flip: Flip, notification: Notification) -> None:
base = self.channel.gotify.url
if not base.endswith("/"):
base += "/"
@ -1392,7 +1392,11 @@ class Gotify(HttpTransport):
url = urljoin(base, "message")
url += "?" + urlencode({"token": self.channel.gotify.token})
ctx = {"check": check, "down_checks": self.down_checks(check)}
ctx = {
"check": flip.owner,
"status": flip.new_status,
"down_checks": self.down_checks(flip.owner),
}
payload = {
"title": tmpl("gotify_title.html", **ctx),
"message": tmpl("gotify_message.html", **ctx),

View file

@ -1,5 +1,5 @@
{% load humanize linemode %}{% linemode %}
{% if check.status == "down" %}
{% if status == "down" %}
{% line %}🔴 The check [{{ check.name_then_code }}]({{ check.cloaked_url }}) is **DOWN**.{% if check.last_ping %} Last ping was {{ check.last_ping|naturaltime }}.{% endif %}{% endline %}
{% else %}
{% line %}🟢 The check [{{ check.name_then_code }}]({{ check.cloaked_url }}) is now **UP**.{% endline %}
@ -9,9 +9,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 }}]({{ c.cloaked_url }}) (last ping: {{ c.last_ping|naturaltime|default:"never" }}){% endline %}
{% endfor %}

View file

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