From a028a02f709081fb39d45f5648cde42b894a2b80 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 23 Oct 2020 07:48:55 -0700 Subject: [PATCH] Limit Turbot home display to hunts a user belongs to Membership is determined by membership in a hunt's primary slack channel. --- turbot/events.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/turbot/events.py b/turbot/events.py index 0a1eb09..1b15f0c 100644 --- a/turbot/events.py +++ b/turbot/events.py @@ -3,7 +3,7 @@ from turbot.blocks import ( ) import turbot.sheets import turbot.slack -from turbot.slack import slack_send_message +from turbot.slack import slack_send_message, slack_channel_members TURBOT_USER_ID = 'U01B9QM4P9R' @@ -83,13 +83,17 @@ def home(turb, user_id): hunt_blocks = [] for hunt in hunts: - if hunt['active']: - hunt_blocks += hunt_block(turb, hunt) + if not hunt['active']: + continue + if user_id not in slack_channel_members(turb.slack_client, + hunt['channel_id']): + continue + hunt_blocks += hunt_block(turb, hunt) return { "type": "home", "blocks": [ - section_block(text_block("*Active hunts*")), + section_block(text_block("*Hunts you belong to*")), divider_block(), * hunt_blocks, actions_block(button_block("New hunt", "new_hunt")) -- 2.45.2