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.

integrations: Extract integration event types returning function.

Satyam Bansal237037270573
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index ed66986f190..9b425d0a8f7 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -830,3 +830,12 @@ DOC_SCREENSHOT_CONFIG: Dict[str, List[BaseScreenshotConfig]] = {
)
],
}
+
+
+def get_all_event_types_for_integration(integration: Integration) -> Optional[List[str]]:
+ integration = INTEGRATIONS[integration.name]
+ if isinstance(integration, WebhookIntegration) and hasattr(
+ integration.function, "_all_event_types"
+ ):
+ return integration.function._all_event_types
+ return None
diff --git a/zerver/views/documentation.py b/zerver/views/documentation.py
index 39c4fe4696d..18e484b4238 100644
--- a/zerver/views/documentation.py
+++ b/zerver/views/documentation.py
@@ -21,6 +21,7 @@ from zerver.lib.integrations import (
META_CATEGORY,
HubotIntegration,
WebhookIntegration,
+ get_all_event_types_for_integration,
)
from zerver.lib.request import REQ, RequestNotes, has_request_variables
from zerver.lib.subdomains import get_subdomain
@@ -345,11 +346,9 @@ def integration_doc(request: HttpRequest, integration_name: str = REQ()) -> Http
context["recommended_stream_name"] = integration.stream_name
if isinstance(integration, WebhookIntegration):
context["integration_url"] = integration.url[3:]
- if (
- hasattr(integration.function, "_all_event_types")
- and integration.function._all_event_types is not None
- ):
- context["all_event_types"] = integration.function._all_event_types
+ all_event_types = get_all_event_types_for_integration(integration)
+ if all_event_types is not None:
+ context["all_event_types"] = all_event_types
if isinstance(integration, HubotIntegration):
context["hubot_docs_url"] = integration.hubot_docs_url