Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to exclude channels with external people #452

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions back/back/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
SLACK_USE_SOCKET = env.bool("SLACK_USE_SOCKET", default=False)
SLACK_APP_TOKEN = env("SLACK_APP_TOKEN", default="")
SLACK_BOT_TOKEN = env("SLACK_BOT_TOKEN", default="")
SLACK_EXCLUDE_EXT_SHARED_CHANNELS = env.bool("SLACK_EXCLUDE_EXT_SHARED_CHANNELS", False)

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
Expand Down
10 changes: 9 additions & 1 deletion back/slack_bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ def get_channels(self):
)
except Exception:
return []
return [[x["name"], x["is_private"]] for x in response["channels"]]
all_channels = [[x["name"], x["is_private"]] for x in response["channels"]]
if settings.SLACK_EXCLUDE_EXT_SHARED_CHANNELS:
all_channels = [
channel
for channel in all_channels
if not channel.get("is_ext_shared", False)
]

return all_channels

def get_all_users(self):
try:
Expand Down
7 changes: 7 additions & 0 deletions docs/config/slackbot.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ settings:
8. Go back to your Slack bot and go to "App Home". Then scroll down till you see: "Show Tabs". Enable the "message tab" and check the "Allow users to send Slash commands and messages from the messages tab".

That's it!


## Importing channels

`SLACK_EXCLUDE_EXT_SHARED_CHANNELS`

Default: `False`. If you don't want to import channels that are being shared with external people, then you can set this to `True` to exclude those.