Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhooks/opsgenie: Support linking to EU instances.
Niloth Pfb74cd3ddfdc
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.pyindex f40fa05988b..2a1d489100b 100644--- a/zerver/lib/integrations.py+++ b/zerver/lib/integrations.py@@ -540,7 +540,17 @@ WEBHOOK_INTEGRATIONS: list[WebhookIntegration] = [WebhookIntegration("opencollective", ["financial"], display_name="Open Collective"),WebhookIntegration("openproject", ["project-management"], display_name="OpenProject"),WebhookIntegration("opensearch", ["monitoring"], display_name="OpenSearch"),- WebhookIntegration("opsgenie", ["meta-integration", "monitoring"]),+ WebhookIntegration(+ "opsgenie",+ ["meta-integration", "monitoring"],+ config_options=[+ WebhookConfigOption(+ name="eu_region",+ description="Use Opsgenie's European service region",+ validator=check_bool,+ )+ ],+ ),WebhookIntegration("pagerduty", ["monitoring"], display_name="PagerDuty"),WebhookIntegration("papertrail", ["monitoring"]),WebhookIntegration("patreon", ["financial"]),diff --git a/zerver/webhooks/opsgenie/view.py b/zerver/webhooks/opsgenie/view.pyindex 33e0d9292d5..898d7a510e4 100644--- a/zerver/webhooks/opsgenie/view.py+++ b/zerver/webhooks/opsgenie/view.py@@ -1,4 +1,5 @@from django.http import HttpRequest, HttpResponse+from pydantic import Jsonfrom zerver.decorator import webhook_viewfrom zerver.lib.response import json_success@@ -32,10 +33,12 @@ def api_opsgenie_webhook(user_profile: UserProfile,*,payload: JsonBodyPayload[WildValue],+ eu_region: Json[bool] = False,) -> HttpResponse:# construct the body of the messageinfo = {"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),@@ -71,7 +74,7 @@ def api_opsgenie_webhook(info["additional_info"] += bullet_template.format(key=display_name, value=value)body_template = """-[Opsgenie alert for {integration_name}](https://app.opsgenie.com/alert/V2#/show/{alert_id}):+[Opsgenie alert for {integration_name}](https://app.{url_region}opsgenie.com/alert/V2#/show/{alert_id}):* **Type**: {alert_type}{additional_info}""".strip()