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: Include all integrations and bots in INTEGRATIONS dict.

Niloth P642c4cabbbe6
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index fcbb406701d..1e4c837dd71 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -11,6 +11,7 @@ from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy
from django.views.decorators.csrf import csrf_exempt
from django_stubs_ext import StrPromise
+from typing_extensions import override
from zerver.lib.storage import static_path
from zerver.lib.validator import check_bool, check_string
@@ -458,6 +459,12 @@ class EmbeddedBotIntegration(Integration):
kwargs["fallback_logo_path"] = self.ZULIP_LOGO_STATIC_PATH_PNG
super().__init__(name, *args, **kwargs)
+ @override
+ def is_enabled_in_catalog(self) -> bool:
+ # Only integrations with docs can be part of the catalog
+ # Embedded bots do not have docs
+ return False
+
EMBEDDED_BOTS: list[EmbeddedBotIntegration] = [
EmbeddedBotIntegration("converter", []),
@@ -1111,12 +1118,18 @@ HUBOT_INTEGRATIONS: list[HubotIntegration] = [
INTEGRATIONS: dict[str, Integration] = {
- integration.name: integration
+ (
+ # To avoid namespace collisions, use a prefix for embedded bots
+ f"embedded_bot_{integration.name}"
+ if isinstance(integration, EmbeddedBotIntegration)
+ else integration.name
+ ): integration
for integration in chain(
INCOMING_WEBHOOK_INTEGRATIONS,
PYTHON_API_INTEGRATIONS,
BOT_INTEGRATIONS,
HUBOT_INTEGRATIONS,
+ EMBEDDED_BOTS,
OTHER_INTEGRATIONS,
)
}
diff --git a/zerver/tests/test_integrations.py b/zerver/tests/test_integrations.py
index 44b298d7ffc..6fcae468d50 100644
--- a/zerver/tests/test_integrations.py
+++ b/zerver/tests/test_integrations.py
@@ -181,3 +181,10 @@ class IntegrationsTestCase(ZulipTestCase):
)
assert not errors, "\n".join(errors)
+
+ def test_embedded_bots_are_disabled_in_catalog(self) -> None:
+ for embedded_bot in EMBEDDED_BOTS:
+ self.assertFalse(
+ embedded_bot.is_enabled_in_catalog(),
+ f"Embedded bot '{embedded_bot.name}' should be disabled from the catalog.",
+ )