Browse Source

Add docstring for dynamic default and slack token get() changes

Harshg999 4 years ago
parent
commit
54c695544f

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

@@ -131,15 +131,19 @@ def is_https_enabled():
   return bool(SSL_CERTIFICATE.get() and SSL_PRIVATE_KEY.get())
   return bool(SSL_CERTIFICATE.get() and SSL_PRIVATE_KEY.get())
 
 
 def get_slack_client_id():
 def get_slack_client_id():
+  """Returns Slack Client ID if set as environment variable else None"""
   return os.environ.get('SLACK_CLIENT_ID')
   return os.environ.get('SLACK_CLIENT_ID')
 
 
 def get_slack_client_secret():
 def get_slack_client_secret():
+  """Returns Slack Client Secret if set as environment variable else None"""
   return os.environ.get('SLACK_CLIENT_SECRET')
   return os.environ.get('SLACK_CLIENT_SECRET')
 
 
 def get_slack_verification_token():
 def get_slack_verification_token():
+  """Returns Slack Verification Token if set as environment variable else None"""
   return os.environ.get('SLACK_VERIFICATION_TOKEN')
   return os.environ.get('SLACK_VERIFICATION_TOKEN')
 
 
 def get_slack_bot_user_token():
 def get_slack_bot_user_token():
+  """Returns Slack Bot User Token if set as environment variable else None"""
   return os.environ.get('SLACK_BOT_USER_TOKEN')
   return os.environ.get('SLACK_BOT_USER_TOKEN')
 
 
 
 

+ 3 - 2
desktop/core/src/desktop/lib/botserver/views.py

@@ -22,6 +22,7 @@ from pprint import pprint
 from django.shortcuts import render
 from django.shortcuts import render
 from django.http import HttpResponse
 from django.http import HttpResponse
 from desktop.lib.django_util import login_notrequired, JsonResponse
 from desktop.lib.django_util import login_notrequired, JsonResponse
+from desktop import conf
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.csrf import csrf_exempt
 
 
 from django.conf import settings
 from django.conf import settings
@@ -29,8 +30,8 @@ from slack_sdk import WebClient
 
 
 LOG = logging.getLogger(__name__)
 LOG = logging.getLogger(__name__)
 
 
-SLACK_VERIFICATION_TOKEN = getattr(settings, 'SLACK_VERIFICATION_TOKEN', None)
-SLACK_BOT_USER_TOKEN = getattr(settings, 'SLACK_BOT_USER_TOKEN', None)
+SLACK_VERIFICATION_TOKEN = conf.SLACK.SLACK_VERIFICATION_TOKEN.get()
+SLACK_BOT_USER_TOKEN = conf.SLACK.SLACK_BOT_USER_TOKEN.get()
 
 
 
 
 slack_client = WebClient(token=SLACK_BOT_USER_TOKEN)
 slack_client = WebClient(token=SLACK_BOT_USER_TOKEN)

+ 0 - 9
desktop/core/src/desktop/settings.py

@@ -819,12 +819,3 @@ try:
 except ValueError:
 except ValueError:
   from desktop.monkey_patches import monkey_patch_md5
   from desktop.monkey_patches import monkey_patch_md5
   monkey_patch_md5(MODULES_TO_PATCH)
   monkey_patch_md5(MODULES_TO_PATCH)
-
-################################################################
-# SLACK API Configurations
-################################################################
-
-SLACK_CLIENT_ID = desktop.conf.SLACK.SLACK_CLIENT_ID.get()
-SLACK_CLIENT_SECRET = desktop.conf.SLACK.SLACK_CLIENT_SECRET.get()
-SLACK_VERIFICATION_TOKEN = desktop.conf.SLACK.SLACK_VERIFICATION_TOKEN.get()
-SLACK_BOT_USER_TOKEN = desktop.conf.SLACK.SLACK_BOT_USER_TOKEN.get()