mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-17 18:22:33 +00:00
Fix the Gotify integration to use Flip.new_status
This commit is contained in:
parent
5b6dfb9101
commit
1aa068553d
4 changed files with 13 additions and 7 deletions
hc/api
templates/integrations
|
@ -18,7 +18,9 @@ class NotifyGotidyTestCase(BaseTestCase):
|
||||||
|
|
||||||
self.check = Check(project=self.project)
|
self.check = Check(project=self.project)
|
||||||
self.check.name = "Foo"
|
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.last_ping = now() - td(minutes=61)
|
||||||
self.check.save()
|
self.check.save()
|
||||||
|
|
||||||
|
|
|
@ -1384,7 +1384,7 @@ class Signal(Transport):
|
||||||
|
|
||||||
|
|
||||||
class Gotify(HttpTransport):
|
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
|
base = self.channel.gotify.url
|
||||||
if not base.endswith("/"):
|
if not base.endswith("/"):
|
||||||
base += "/"
|
base += "/"
|
||||||
|
@ -1392,7 +1392,11 @@ class Gotify(HttpTransport):
|
||||||
url = urljoin(base, "message")
|
url = urljoin(base, "message")
|
||||||
url += "?" + urlencode({"token": self.channel.gotify.token})
|
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 = {
|
payload = {
|
||||||
"title": tmpl("gotify_title.html", **ctx),
|
"title": tmpl("gotify_title.html", **ctx),
|
||||||
"message": tmpl("gotify_message.html", **ctx),
|
"message": tmpl("gotify_message.html", **ctx),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% load humanize linemode %}{% linemode %}
|
{% 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 %}
|
{% 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 %}
|
{% else %}
|
||||||
{% line %}🟢 The check [{{ check.name_then_code }}]({{ check.cloaked_url }}) is now **UP**.{% endline %}
|
{% line %}🟢 The check [{{ check.name_then_code }}]({{ check.cloaked_url }}) is now **UP**.{% endline %}
|
||||||
|
@ -9,9 +9,9 @@
|
||||||
{% line %}{% endline %}
|
{% line %}{% endline %}
|
||||||
{% if down_checks %}
|
{% if down_checks %}
|
||||||
{% if down_checks|length > 10 %}
|
{% 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 %}
|
{% 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 %}
|
{% for c in down_checks %}
|
||||||
{% line %}- [{{ c.name_then_code }}]({{ c.cloaked_url }}) (last ping: {{ c.last_ping|naturaltime|default:"never" }}){% endline %}
|
{% line %}- [{{ c.name_then_code }}]({{ c.cloaked_url }}) (last ping: {{ c.last_ping|naturaltime|default:"never" }}){% endline %}
|
||||||
{% endfor %}
|
{% 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