浏览代码

Add config flag to globally turn on/off the Slack Integration

Harshg999 4 年之前
父节点
当前提交
d7e779be75

+ 8 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -816,6 +816,14 @@
    ## collection_interval=30000
 
 
+  # Configuration options for Slack
+  # ------------------------------------------------------------------------
+  [[slack]]
+
+   # Enable slack bot server URLs "/slack/"
+   ## enable_slack_integration=True
+
+
   # Configuration options for the request Tracing
   # ------------------------------------------------------------------------
   [[tracing]]

+ 11 - 0
desktop/core/src/desktop/conf.py

@@ -703,6 +703,17 @@ METRICS = ConfigSection(
   )
 )
 
+SLACK = ConfigSection(
+  key='slack',
+  help=_("""Configuration options for slack """),
+  members=dict(
+    ENABLE_SLACK_INTEGRATION=Config(
+      key='enable_slack_integration',
+      help=_('Enable slack bot server URLs "/slack/"'),
+      default=True,
+      type=coerce_bool),
+  )
+)
 
 ANALYTICS = ConfigSection(
   key='analytics',

+ 3 - 3
desktop/core/src/desktop/lib/botserver/apps.py

@@ -15,8 +15,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from django.apps import AppConfig
+# from django.apps import AppConfig
 
 
-class BotserverConfig(AppConfig):
-  name = 'botserver'
+# class BotserverConfig(AppConfig):
+#   name = 'botserver'

+ 1 - 1
desktop/core/src/desktop/lib/botserver/urls.py

@@ -16,7 +16,7 @@
 # limitations under the License.
 
 from django.conf.urls import url
-from . import views
+from desktop.lib.botserver import views
 
 urlpatterns = [
   url(r'^events/', views.home, name='home')

+ 3 - 2
desktop/core/src/desktop/urls.py

@@ -46,7 +46,7 @@ from desktop import views as desktop_views
 from desktop import api as desktop_api
 from desktop import api2 as desktop_api2
 from desktop.auth import views as desktop_auth_views
-from desktop.conf import METRICS, USE_NEW_EDITOR, ENABLE_DJANGO_DEBUG_TOOL, ANALYTICS, has_connectors, ENABLE_PROMETHEUS
+from desktop.conf import METRICS, USE_NEW_EDITOR, ENABLE_DJANGO_DEBUG_TOOL, ANALYTICS, has_connectors, ENABLE_PROMETHEUS, SLACK
 from desktop.configuration import api as desktop_configuration_api
 from desktop.lib.vcs import api as desktop_lib_vcs_api
 from desktop.settings import is_oidc_configured
@@ -275,6 +275,7 @@ if is_oidc_configured():
     url(r'^oidc/', include('mozilla_django_oidc.urls')),
   ]
 
-urlpatterns += [
+if SLACK.ENABLE_SLACK_INTEGRATION.get():
+  urlpatterns += [
     url(r'^slack/', include('desktop.lib.botserver.urls')),
   ]