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_participants URL option.

sathwikshetty33dbf1590a1984
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 6aaea11cebb..d85e5318daf 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -728,6 +728,11 @@ INCOMING_WEBHOOK_INTEGRATIONS: list[IncomingWebhookIntegration] = [
label="Include primary topics in the notifications",
input_type="checkbox_enabled",
),
+ WebhookUrlOption(
+ "include_participants",
+ label="Include participant names in the notifications",
+ input_type="checkbox_enabled",
+ ),
],
),
IncomingWebhookIntegration(
diff --git a/zerver/webhooks/gong/tests.py b/zerver/webhooks/gong/tests.py
index 775a4b018ea..7124e84d067 100644
--- a/zerver/webhooks/gong/tests.py
+++ b/zerver/webhooks/gong/tests.py
@@ -149,6 +149,16 @@ class GongHookTests(WebhookTestCase):
content_type="application/json",
)
+ def test_call_with_participants_disabled(self) -> None:
+ self.url = self.build_webhook_url(include_participants="false")
+ intro = self.MESSAGE_INTRO.format(title=self.CALL_TITLE)
+ self.check_webhook(
+ "call_completed",
+ self.EXPECTED_TOPIC,
+ f"{intro}\n\n{self.TRACKERS_SECTION}\n\n{self.TOPICS_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 e7bb171c3b3..6f8579fbf78 100644
--- a/zerver/webhooks/gong/view.py
+++ b/zerver/webhooks/gong/view.py
@@ -31,10 +31,12 @@ class Helper:
payload: WildValue,
include_trackers: bool,
include_topics: bool,
+ include_participants: bool,
) -> None:
self.payload = payload
self.include_trackers = include_trackers
self.include_topics = include_topics
+ self.include_participants = include_participants
def format_duration_to_string(duration: int) -> str:
@@ -161,8 +163,7 @@ def handle_call_processed_message(helper: Helper) -> tuple[str, str]:
time=datetime_to_global_time(meta_data["started"].tame(check_iso_datetime)),
duration=format_duration_to_string(meta_data["duration"].tame(check_int)),
)
-
- if participants := get_participants(call_data["parties"]):
+ if helper.include_participants and (participants := get_participants(call_data["parties"])):
body += "\n\n" + SECTION_TEMPLATE.format(heading="Participants", body=participants)
if content := call_data.get("content"):
@@ -192,8 +193,9 @@ def api_gong_webhook(
payload: JsonBodyPayload[WildValue],
include_trackers: Json[bool] = True,
include_topics: Json[bool] = True,
+ include_participants: Json[bool] = True,
) -> HttpResponse:
- helper = Helper(payload, include_trackers, include_topics)
+ helper = Helper(payload, include_trackers, include_topics, include_participants)
if payload.get("isTest").tame(check_bool):
topic, body = handle_test_message(helper)
else: