diff --git a/hc/api/tests/test_notify_gotify.py b/hc/api/tests/test_notify_gotify.py index 5b7de13b..467020e1 100644 --- a/hc/api/tests/test_notify_gotify.py +++ b/hc/api/tests/test_notify_gotify.py @@ -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() diff --git a/hc/api/transports.py b/hc/api/transports.py index 2a1669d2..4db69bdd 100644 --- a/hc/api/transports.py +++ b/hc/api/transports.py @@ -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), diff --git a/templates/integrations/gotify_message.html b/templates/integrations/gotify_message.html index 27529e34..f8909d82 100644 --- a/templates/integrations/gotify_message.html +++ b/templates/integrations/gotify_message.html @@ -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 %} diff --git a/templates/integrations/gotify_title.html b/templates/integrations/gotify_title.html index eb298b98..002e0f4b 100644 --- a/templates/integrations/gotify_title.html +++ b/templates/integrations/gotify_title.html @@ -1 +1 @@ -{{ check.name_then_code|safe }} is {{ check.status|upper }} +{{ check.name_then_code|safe }} is {{ status|upper }}