From 40d5f78d0cf8ab1e8c76d97d82cf3889e07604c9 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 <sandeepsajan0@gmail.com> Date: Wed, 22 Jun 2022 12:40:30 +0530 Subject: [PATCH] Update settings defaults and code accordingly --- hypha/apply/activity/messaging.py | 4 +--- hypha/apply/activity/tests/test_messaging.py | 12 ------------ hypha/settings/base.py | 4 ++-- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py index 4a08bb273..944532c95 100644 --- a/hypha/apply/activity/messaging.py +++ b/hypha/apply/activity/messaging.py @@ -716,10 +716,8 @@ class SlackAdapter(AdapterBase): def send_message(self, message, recipient, source, **kwargs): target_rooms = self.slack_channels(source, **kwargs) - if not self.destination or not any(target_rooms) or not settings.SLACK_TOKEN: + if not any(target_rooms) or not settings.SLACK_TOKEN: errors = list() - if not self.destination: - errors.append('Destination URL') if not target_rooms: errors.append('Room ID') if not settings.SLACK_TOKEN: diff --git a/hypha/apply/activity/tests/test_messaging.py b/hypha/apply/activity/tests/test_messaging.py index 99cc3281f..b2cdac281 100644 --- a/hypha/apply/activity/tests/test_messaging.py +++ b/hypha/apply/activity/tests/test_messaging.py @@ -349,18 +349,6 @@ class TestSlackAdapter(AdapterMixin, TestCase): messages = adapter.send_message('my message', '', source=submission) self.assertEqual(messages, error_message) - @override_settings( - SLACK_ENDPOINT_URL=None, - SLACK_DESTINATION_ROOM=target_room, - SLACK_BACKEND=backend, - SLACK_TOKEN=token, - ) - def test_cant_send_with_no_url(self): - error_message = "Missing configuration: Destination URL" - adapter = SlackAdapter() - submission = ApplicationSubmissionFactory() - messages = adapter.send_message('my message', '', source=submission) - self.assertEqual(messages, error_message) @override_settings( SLACK_ENDPOINT_URL=target_url, diff --git a/hypha/settings/base.py b/hypha/settings/base.py index ba35678a1..f8a2e68a1 100644 --- a/hypha/settings/base.py +++ b/hypha/settings/base.py @@ -522,9 +522,9 @@ SEND_READY_FOR_REVIEW = env.bool('SEND_READY_FOR_REVIEW', True) # Django Slack settings SLACK_TOKEN = env.str('SLACK_TOKEN', None) -SLACK_USERNAME = env.str('SLACK_USERNAME', 'bot') +SLACK_USERNAME = env.str('SLACK_USERNAME', 'Hypha') SLACK_BACKEND = 'django_slack.backends.CeleryBackend' # UrllibBackend can be used for sync -SLACK_ENDPOINT_URL = env.str('SLACK_ENDPOINT_URL', None) +SLACK_ENDPOINT_URL = env.str('SLACK_ENDPOINT_URL', 'https://slack.com/api/chat.postMessage') # Slack settings SLACK_DESTINATION_ROOM = env.str('SLACK_DESTINATION_ROOM', None) -- GitLab