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,28 @@
# Zulip Opsgenie integration
Get Zulip notifications for your Opsgenie events!
{start_tabs}
1. {!create-an-incoming-webhook.md!}
1. {!generate-webhook-url-basic.md!}
1. Go to <https://app.opsgenie.com/integration>. Click on
**Add New Integrations**, and select **Webhook**.
1. Set **Name** to a name of your choice, such as `Zulip`. Set
**Webhook URL** to the URL generated above, and click on
**Save Integration**.
{end_tabs}
{!congrats.md!}
![](/static/images/integrations/opsgenie/001.png)
{!event-filtering-additional-feature.md!}
### Related documentation
{!webhooks-url-specification.md!}

View File

@@ -0,0 +1,24 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452224764002246,
"tags": [
"tag1", "tag2"
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":""
},
"action":"Acknowledge",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,25 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452275002000962,
"tags": [
"tag1", "tag2"
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":"",
"note":"note to test alert"
},
"action":"AddNote",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,25 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452274617001925,
"tags": [
"tag1", "tag2"
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":"",
"recipient":"team2_escalation"
},
"action":"AddRecipient",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,25 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452275002000962,
"tags": [
"tag1", "tag2", "tag3"
],
"addedTags":"tag1,tag2,tag3",
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":""
},
"action":"AddTags",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,25 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452256147001924,
"tags": [
"tag1", "tag2"
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":"",
"team":"team2"
},
"action":"AddTeam",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,25 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452374669001603,
"tags": [
"tag1", "tag2"
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":"",
"owner" : "user2@ifountain.com"
},
"action":"AssignOwnership",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,23 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452374669001603,
"tags": [
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":""
},
"action":"Close",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,39 @@
{
"action":"Create",
"alert":{
"alertId":"ec03dad6-62c8-4c94-b38b-d88f398e900f",
"message":"another alert",
"tags":[
"vip"
],
"tinyId":"2",
"source":"test@example.com",
"entity":"Server",
"alias":"alert-alias",
"createdAt":1502709956288,
"updatedAt":1502709956288000110,
"username":"test@example.com",
"userId":"8d43133c-a002-4e95-bf2b-2d6f95e47c96",
"recipients":[
],
"teams":[
],
"insertedAt":1502709956288000110,
"priority":3
},
"source":{
"name":"web",
"type":"API"
},
"integrationId":"daca46c6-e26b-4dda-8f8a-21f6db7eeaef",
"integrationName":"Webhook",
"integrationType":"Webhook",
"alertFlowContext":{
"requestId":"df3ad546-c7b6-4520-8de3-52bb12d1e99a",
"traceId":"df3ad546-c7b6-4520-8de3-52bb12d1e99a",
"content":{
}
}
}

View File

@@ -0,0 +1,24 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452275002000962,
"tags": [
"tag1", "tag2"
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":""
},
"action":"TestAction",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,21 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"tinyId":"23",
"alias":"aliastest",
"entity":"",
"message":"test alert",
"updatedAt":1420452374669001603,
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"username":"fili@ifountain.com",
"source":"fili@ifountain.com",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d"
},
"action":"Delete",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,21 @@
{
"escalationId":"51859f57-7fad-467b-ad79-59acbc69cb6a",
"headers":{
"foo":"bar"
},
"integrationName":"Webhook_Test",
"escalationNotify":{
"name":"test@ifountain.com",
"id":"64818849-71d6-40ce-87c6-ed5e588702fd",
"type":"default",
"entity":"user"
},
"integrationId":"868be72a-8015-432e-8b23-c1f7f4374baa",
"escalationName":"test_esc",
"alert":{
"alertId":"7ba97e3a-d328-4b5e-8f9a-39e945a3869a"
},
"escalationTime":0,
"action":"Escalate",
"repeatCount":0
}

View File

@@ -0,0 +1,25 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452275002000962,
"tags": [
"tag1", "tag2"
],
"removedTags":"tag3",
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":""
},
"action":"RemoveTags",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,25 @@
{
"integrationType":"Integration1",
"alert":{
"createdAt":1470226893192,
"tinyId":"47",
"alias":"8a745a79-3ed3-4044-8427-98e067c0623c",
"alertId":"8a745a79-3ed3-4044-8427-98e067c0623c",
"source":"test@test.com",
"message":"message test",
"userId":"ac6a9ab7-98fe-4256-8a0e-30dc082a55e7",
"entity":"",
"tags":[
"tag1","tag2"
],
"updatedAt":1470383477928000335,
"username":"test@test.com"
},
"integrationName":"Webhook",
"action":"TakeOwnership",
"integrationId":"fd8755c1-7a5e-4829-9ecc-8990e1a2eed3",
"source":{
"name":"",
"type":"web"
}
}

View File

@@ -0,0 +1,24 @@
{
"source":{
"name":"",
"type":"web"
},
"alert":{
"updatedAt":1420452224764002246,
"tags": [
"tag1", "tag2"
],
"message":"test alert",
"username":"fili@ifountain.com",
"alertId":"052652ac-5d1c-464a-812a-7dd18bbfba8c",
"source":"fili@ifountain.com",
"alias":"aliastest",
"tinyId":"23",
"createdAt":1420452191104,
"userId":"daed1180-0ce8-438b-8f8e-57e1a5920a2d",
"entity":""
},
"action":"UnAcknowledge",
"integrationId":"37c8f316-17c6-49d7-899b-9c7e540c048d",
"integrationName":"Integration1"
}

View File

@@ -0,0 +1,230 @@
from zerver.lib.test_classes import WebhookTestCase
class OpsgenieHookTests(WebhookTestCase):
def test_acknowledge_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: Acknowledge
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"acknowledge",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addnote_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: AddNote
* **Note**: note to test alert
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"addnote",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addrecipient_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: AddRecipient
* **Recipient**: team2_escalation
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"addrecipient",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addtags_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: AddTags
* **Tags added**: tag1,tag2,tag3
* **Message**: test alert
* **Tags**: `tag1`, `tag2`, `tag3`
""".strip()
self.check_webhook(
"addtags",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addteam_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: AddTeam
* **Team added**: team2
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"addteam",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_assignownership_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: AssignOwnership
* **Assigned owner**: user2@ifountain.com
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"assignownership",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_close_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: Close
* **Message**: test alert
""".strip()
self.check_webhook(
"close",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_create_alert(self) -> None:
expected_topic_name = "Webhook"
expected_message = """
[Opsgenie alert for Webhook](https://app.opsgenie.com/alert/V2#/show/ec03dad6-62c8-4c94-b38b-d88f398e900f):
* **Type**: Create
* **Message**: another alert
* **Tags**: `vip`
""".strip()
self.check_webhook(
"create",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customaction_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: TestAction
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"customaction",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_delete_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: Delete
* **Message**: test alert
""".strip()
self.check_webhook(
"delete",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_escalate_alert(self) -> None:
expected_topic_name = "Webhook_Test"
expected_message = """
[Opsgenie alert for Webhook_Test](https://app.opsgenie.com/alert/V2#/show/7ba97e3a-d328-4b5e-8f9a-39e945a3869a):
* **Type**: Escalate
* **Escalation**: test_esc
""".strip()
self.check_webhook(
"escalate",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_removetags_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: RemoveTags
* **Tags removed**: tag3
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"removetags",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_takeownership_alert(self) -> None:
expected_topic_name = "Webhook"
expected_message = """
[Opsgenie alert for Webhook](https://app.opsgenie.com/alert/V2#/show/8a745a79-3ed3-4044-8427-98e067c0623c):
* **Type**: TakeOwnership
* **Message**: message test
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"takeownership",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_unacknowledge_alert(self) -> None:
expected_topic_name = "Integration1"
expected_message = """
[Opsgenie alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c):
* **Type**: UnAcknowledge
* **Message**: test alert
* **Tags**: `tag1`, `tag2`
""".strip()
self.check_webhook(
"unacknowledge",
expected_topic_name,
expected_message,
content_type="application/x-www-form-urlencoded",
)

View File

@@ -0,0 +1,85 @@
from django.http import HttpRequest, HttpResponse
from pydantic import Json
from zerver.decorator import webhook_view
from zerver.lib.response import json_success
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
ALL_EVENT_TYPES = [
"AddTeam",
"UnAcknowledge",
"AddNote",
"TestAction",
"Close",
"Escalate",
"AddRecipient",
"RemoveTags",
"Acknowledge",
"Delete",
"AddTags",
"TakeOwnership",
"Create",
"AssignOwnership",
]
@webhook_view("Opsgenie", all_event_types=ALL_EVENT_TYPES)
@typed_endpoint
def api_opsgenie_webhook(
request: HttpRequest,
user_profile: UserProfile,
*,
payload: JsonBodyPayload[WildValue],
eu_region: Json[bool] = False,
) -> HttpResponse:
# construct the body of the message
info = {
"additional_info": "",
"url_region": "eu." if eu_region else "",
"alert_type": payload["action"].tame(check_string),
"alert_id": payload["alert"]["alertId"].tame(check_string),
"integration_name": payload["integrationName"].tame(check_string),
"tags": ", ".join(
"`" + tag.tame(check_string) + "`" for tag in payload["alert"].get("tags", [])
),
}
topic_name = info["integration_name"]
bullet_template = "* **{key}**: {value}\n"
fields = {
"note": "Note",
"recipient": "Recipient",
"addedTags": "Tags added",
"team": "Team added",
"owner": "Assigned owner",
"removedTags": "Tags removed",
"message": "Message",
"tags": "Tags",
"escalationName": "Escalation",
}
for field, display_name in fields.items():
if field == "tags" and info["tags"]:
value = info["tags"]
elif field == "escalationName" and field in payload:
value = payload[field].tame(check_string)
elif field in payload.get("alert", {}) and field != "tags":
value = payload["alert"][field].tame(check_string)
else:
continue
info["additional_info"] += bullet_template.format(key=display_name, value=value)
body_template = """
[Opsgenie alert for {integration_name}](https://app.{url_region}opsgenie.com/alert/V2#/show/{alert_id}):
* **Type**: {alert_type}
{additional_info}
""".strip()
body = body_template.format(**info)
check_send_webhook_message(request, user_profile, topic_name, body, info["alert_type"])
return json_success(request)