Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks/gong: Add include_topics URL option.

sathwikshetty33311514b57938
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 73b75ab34de..6aaea11cebb 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -722,7 +722,12 @@ INCOMING_WEBHOOK_INTEGRATIONS: list[IncomingWebhookIntegration] = [
"include_trackers",
label="Include primary trackers in the notifications",
input_type="checkbox_enabled",
- )
+ ),
+ WebhookUrlOption(
+ "include_topics",
+ label="Include primary topics in the notifications",
+ input_type="checkbox_enabled",
+ ),
],
),
IncomingWebhookIntegration(
diff --git a/zerver/webhooks/gong/tests.py b/zerver/webhooks/gong/tests.py
index a7ef2fa5d9e..775a4b018ea 100644
--- a/zerver/webhooks/gong/tests.py
+++ b/zerver/webhooks/gong/tests.py
@@ -139,6 +139,16 @@ class GongHookTests(WebhookTestCase):
content_type="application/json",
)
+ def test_call_with_top_topics_disabled(self) -> None:
+ self.url = self.build_webhook_url(include_topics="false")
+ intro = self.MESSAGE_INTRO.format(title=self.CALL_TITLE)
+ self.check_webhook(
+ "call_completed",
+ self.EXPECTED_TOPIC,
+ f"{intro}\n\n{self.PARTICIPANTS_SECTION}\n\n{self.TRACKERS_SECTION}",
+ content_type="application/json",
+ )
+
def test_get_participants(self) -> None:
name = KEVIN_NAME
title = "Customer Success Manager"
diff --git a/zerver/webhooks/gong/view.py b/zerver/webhooks/gong/view.py
index 548b7b8c3bc..e7bb171c3b3 100644
--- a/zerver/webhooks/gong/view.py
+++ b/zerver/webhooks/gong/view.py
@@ -26,9 +26,15 @@ PARTICIPANTS_LIMIT = 5
class Helper:
- def __init__(self, payload: WildValue, include_trackers: bool) -> None:
+ def __init__(
+ self,
+ payload: WildValue,
+ include_trackers: bool,
+ include_topics: bool,
+ ) -> None:
self.payload = payload
self.include_trackers = include_trackers
+ self.include_topics = include_topics
def format_duration_to_string(duration: int) -> str:
@@ -168,7 +174,11 @@ def handle_call_processed_message(helper: Helper) -> tuple[str, str]:
body += "\n\n" + SECTION_TEMPLATE.format(
heading="Top Trackers (by count)", body=top_trackers
)
- if "topics" in content and (topics := get_topics(content["topics"])):
+ if (
+ helper.include_topics
+ and "topics" in content
+ and (topics := get_topics(content["topics"]))
+ ):
body += "\n\n" + TOPICS_TEMPLATE.format(topics=topics)
return topic, body
@@ -181,8 +191,9 @@ def api_gong_webhook(
*,
payload: JsonBodyPayload[WildValue],
include_trackers: Json[bool] = True,
+ include_topics: Json[bool] = True,
) -> HttpResponse:
- helper = Helper(payload, include_trackers)
+ helper = Helper(payload, include_trackers, include_topics)
if payload.get("isTest").tame(check_bool):
topic, body = handle_test_message(helper)
else: