diff --git a/hc/api/tests/test_notify_zulip.py b/hc/api/tests/test_notify_zulip.py index 614bee24..8444caed 100644 --- a/hc/api/tests/test_notify_zulip.py +++ b/hc/api/tests/test_notify_zulip.py @@ -19,7 +19,9 @@ class NotifyZulipTestCase(BaseTestCase): self.check = Check(project=self.project) self.check.name = "Foobar" - 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 f148a07b..5d6bfa7c 100644 --- a/hc/api/transports.py +++ b/hc/api/transports.py @@ -1197,21 +1197,22 @@ class Zulip(HttpTransport): raise TransportError(message) - def notify(self, check: Check, notification: Notification) -> None: + def notify_flip(self, flip: Flip, notification: Notification) -> None: if not settings.ZULIP_ENABLED: raise TransportError("Zulip notifications are not enabled.") topic = self.channel.zulip.topic if not topic: - topic = tmpl("zulip_topic.html", check=check) + topic = tmpl("zulip_topic.html", check=flip.owner, status=flip.new_status) url = self.channel.zulip.site + "/api/v1/messages" auth = (self.channel.zulip.bot_email, self.channel.zulip.api_key) + content = tmpl("zulip_content.html", check=flip.owner, status=flip.new_status) data = { "type": self.channel.zulip.mtype, "to": self.channel.zulip.to, "topic": topic, - "content": tmpl("zulip_content.html", check=check), + "content": content, } self.post(url, data=data, auth=auth) diff --git a/templates/integrations/zulip_content.html b/templates/integrations/zulip_content.html index 387561bc..1d53c076 100644 --- a/templates/integrations/zulip_content.html +++ b/templates/integrations/zulip_content.html @@ -1,6 +1,6 @@ {% load hc_extras humanize %} -[{{ check.name_then_code }}]({{ check.cloaked_url }}) is **{{ check.status|upper }}**. {% if check.status == "down" and check.last_ping %}Last ping was {{ check.last_ping|naturaltime }}.{% endif %} +[{{ check.name_then_code }}]({{ check.cloaked_url }}) is **{{ status|upper }}**. {% if status == "down" and check.last_ping %}Last ping was {{ check.last_ping|naturaltime }}.{% endif %} {% if check.desc %} --- diff --git a/templates/integrations/zulip_topic.html b/templates/integrations/zulip_topic.html index eb298b98..002e0f4b 100644 --- a/templates/integrations/zulip_topic.html +++ b/templates/integrations/zulip_topic.html @@ -1 +1 @@ -{{ check.name_then_code|safe }} is {{ check.status|upper }} +{{ check.name_then_code|safe }} is {{ status|upper }}