mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-05 05:15:26 +00:00
Fix the Zulip integration to use Flip.new_status
This commit is contained in:
parent
6631a5f76a
commit
5bdb01baf9
4 changed files with 9 additions and 6 deletions
hc/api
templates/integrations
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 %}
|
||||
---
|
||||
|
|
|
@ -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