diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py index d3872bab38d50dae1de453ee8274f38937cd9a0a..d2c7b76cbd78218fdb53d1af1193f0f26d5124d8 100644 --- a/hypha/apply/activity/messaging.py +++ b/hypha/apply/activity/messaging.py @@ -430,6 +430,7 @@ class SlackAdapter(AdapterBase): self.destination = settings.SLACK_DESTINATION_URL self.target_room = settings.SLACK_DESTINATION_ROOM self.comments_room = settings.SLACK_DESTINATION_ROOM_COMMENTS + self.comments_type = settings.SLACK_TYPE_COMMENTS def slack_links(self, links, sources): return ', '.join( @@ -603,11 +604,17 @@ class SlackAdapter(AdapterBase): target_rooms.extend(extra_rooms) try: - if self.comments_room and kwargs['comment']: - target_rooms.extend([self.comments_room]) + comment = kwargs['comment'] except KeyError: - # Not a comment. + # Not a comment, no extra rooms. pass + else: + if self.comments_room: + if any(self.comments_type): + if comment.visibility in self.comments_type: + target_rooms.extend([self.comments_room]) + else: + target_rooms.extend([self.comments_room]) # Make sure each channel name starts with a "#". target_rooms = [ diff --git a/hypha/settings/base.py b/hypha/settings/base.py index f9cedc9c54e31200cd315760cca3f7973814c430..d3936a389ce98385985667d63b630ddbae301647 100644 --- a/hypha/settings/base.py +++ b/hypha/settings/base.py @@ -507,6 +507,10 @@ if not SEND_MESSAGES: SLACK_DESTINATION_URL = env.get('SLACK_DESTINATION_URL', None) SLACK_DESTINATION_ROOM = env.get('SLACK_DESTINATION_ROOM', None) SLACK_DESTINATION_ROOM_COMMENTS = env.get('SLACK_DESTINATION_ROOM_COMMENTS', None) +if 'SLACK_TYPE_COMMENTS' in env: + SLACK_TYPE_COMMENTS = env['SLACK_TYPE_COMMENTS'].split(',') +else: + SLACK_TYPE_COMMENTS = [] # Celery config