snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-15 15:05:30 +05:00
commit 64898b2c79
8999 changed files with 1757358 additions and 0 deletions

View File

View File

@@ -0,0 +1,42 @@
# Zulip UptimeRobot integration
Receive Zulip notifications from UptimeRobot!
{start_tabs}
1. {!create-an-incoming-webhook.md!}
1. {!generate-webhook-url-basic.md!}
1. On UptimeRobot, go to **My Settings**, and select **Add Alert Contact**.
1. Set **Alert Contact Type** to **webhook**, set **Friendly Name** to
a name of your choice, such as `Zulip`, and set **URL to notify** to the
URL generated above.
1. Under **POST Value (JSON Format)**, select **Send as JSON (application/json)**,
and then set the value to:
{
"monitor_url":"*monitorURL*",
"monitor_friendly_name":"*monitorFriendlyName*",
"alert_type":"*alertType*",
"alert_type_friendly_name":"*alertTypeFriendlyName*",
"alert_details":"*alertDetails*",
"alert_friendly_duration":"*alertFriendlyDuration*"
}
1. Set **Enable Notifications For** the [events](#filtering-incoming-events)
you'd like to be notified about, and save the form.
{end_tabs}
{!congrats.md!}
![](/static/images/integrations/uptimerobot/001.png)
{!event-filtering-additional-feature.md!}
### Related documentation
{!webhooks-url-specification.md!}

View File

@@ -0,0 +1,7 @@
{
"monitor_url": "server1.example.com",
"alert_type": "1",
"alert_type_friendly_name": "Down",
"alert_details": "Host Is Unreachable",
"alert_friendly_duration": "*alertFriendlyDuration*"
}

View File

@@ -0,0 +1,8 @@
{
"monitor_url": "server1.example.com",
"monitor_friendly_name": "Web Server",
"alert_type": "1",
"alert_type_friendly_name": "Down",
"alert_details": "Host Is Unreachable",
"alert_friendly_duration": "*alertFriendlyDuration*"
}

View File

@@ -0,0 +1,8 @@
{
"monitor_url": "server2.example.com",
"monitor_friendly_name": "Mail Server",
"alert_type": "2",
"alert_type_friendly_name": "Up",
"alert_details": "Host Is Reachable",
"alert_friendly_duration": "44 minutes and 37 seconds"
}

View File

@@ -0,0 +1,43 @@
from zerver.lib.send_email import FromAddress
from zerver.lib.test_classes import WebhookTestCase
from zerver.models import Recipient
from zerver.webhooks.uptimerobot.view import MISCONFIGURED_PAYLOAD_ERROR_MESSAGE
class UptimeRobotHookTests(WebhookTestCase):
def test_uptimerobot_monitor_down(self) -> None:
"""
Tests if uptimerobot monitor down is handled correctly
"""
expected_topic_name = "Web Server"
expected_message = "Web Server (server1.example.com) is DOWN (Host Is Unreachable)."
self.check_webhook("uptimerobot_monitor_down", expected_topic_name, expected_message)
def test_uptimerobot_monitor_up(self) -> None:
"""
Tests if uptimerobot monitor up is handled correctly
"""
expected_topic_name = "Mail Server"
expected_message = """
Mail Server (server2.example.com) is back UP (Host Is Reachable).
It was down for 44 minutes and 37 seconds.
""".strip()
self.check_webhook("uptimerobot_monitor_up", expected_topic_name, expected_message)
def test_uptimerobot_invalid_payload_with_missing_data(self) -> None:
"""
Tests if invalid UptimeRobot payloads are handled correctly
"""
self.url = self.build_webhook_url()
payload = self.get_body("uptimerobot_invalid_payload_with_missing_data")
result = self.client_post(self.url, payload, content_type="application/json")
self.assert_json_error(result, "Invalid payload")
expected_message = MISCONFIGURED_PAYLOAD_ERROR_MESSAGE.format(
bot_name=self.test_user.full_name,
support_email=FromAddress.SUPPORT,
).strip()
msg = self.get_last_message()
self.assertEqual(msg.content, expected_message)
self.assertEqual(msg.recipient.type, Recipient.DIRECT_MESSAGE_GROUP)

View File

@@ -0,0 +1,94 @@
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext as _
from zerver.actions.message_send import send_rate_limited_pm_notification_to_bot_owner
from zerver.decorator import webhook_view
from zerver.lib.exceptions import JsonableError, UnsupportedWebhookEventTypeError
from zerver.lib.response import json_success
from zerver.lib.send_email import FromAddress
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
from zerver.lib.validator import WildValue, check_string
from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile
MISCONFIGURED_PAYLOAD_ERROR_MESSAGE = """
Hi there! Your bot {bot_name} just received a UptimeRobot payload that is missing
some data that Zulip requires. This usually indicates a configuration issue
in your UptimeRobot webhook settings. Please make sure that you set the required parameters
when configuring the UptimeRobot webhook. Contact {support_email} if you
need further help!
"""
UPTIMEROBOT_TOPIC_TEMPLATE = "{monitor_friendly_name}"
UPTIMEROBOT_MESSAGE_UP_TEMPLATE = """
{monitor_friendly_name} ({monitor_url}) is back UP ({alert_details}).
It was down for {alert_friendly_duration}.
""".strip()
UPTIMEROBOT_MESSAGE_DOWN_TEMPLATE = (
"{monitor_friendly_name} ({monitor_url}) is DOWN ({alert_details})."
)
ALL_EVENT_TYPES = ["up", "down"]
@webhook_view("UptimeRobot", all_event_types=ALL_EVENT_TYPES)
@typed_endpoint
def api_uptimerobot_webhook(
request: HttpRequest,
user_profile: UserProfile,
*,
payload: JsonBodyPayload[WildValue],
) -> HttpResponse:
event_type = payload["alert_type_friendly_name"].tame(check_string)
if event_type == "Up":
event = "up"
elif event_type == "Down":
event = "down"
try:
body = get_body_for_http_request(payload, event_type)
topic_name = get_topic_for_http_request(payload)
except ValidationError:
message = MISCONFIGURED_PAYLOAD_ERROR_MESSAGE.format(
bot_name=user_profile.full_name,
support_email=FromAddress.SUPPORT,
).strip()
send_rate_limited_pm_notification_to_bot_owner(user_profile, user_profile.realm, message)
raise JsonableError(_("Invalid payload"))
check_send_webhook_message(request, user_profile, topic_name, body, event)
return json_success(request)
def get_topic_for_http_request(payload: WildValue) -> str:
return UPTIMEROBOT_TOPIC_TEMPLATE.format(
monitor_friendly_name=payload["monitor_friendly_name"].tame(check_string)
)
def get_body_for_http_request(payload: WildValue, event_type: str) -> str:
if event_type == "Up":
monitor_friendly_name = payload["monitor_friendly_name"].tame(check_string)
monitor_url = payload["monitor_url"].tame(check_string)
alert_details = payload["alert_details"].tame(check_string)
alert_friendly_duration = payload["alert_friendly_duration"].tame(check_string)
body = UPTIMEROBOT_MESSAGE_UP_TEMPLATE.format(
monitor_friendly_name=monitor_friendly_name,
monitor_url=monitor_url,
alert_details=alert_details,
alert_friendly_duration=alert_friendly_duration,
)
elif event_type == "Down":
monitor_friendly_name = payload["monitor_friendly_name"].tame(check_string)
monitor_url = payload["monitor_url"].tame(check_string)
alert_details = payload["alert_details"].tame(check_string)
body = UPTIMEROBOT_MESSAGE_DOWN_TEMPLATE.format(
monitor_friendly_name=monitor_friendly_name,
monitor_url=monitor_url,
alert_details=alert_details,
)
else:
raise UnsupportedWebhookEventTypeError(event_type)
return body