From: Carl Worth Date: Fri, 23 Oct 2020 14:48:55 +0000 (-0700) Subject: Limit Turbot home display to hunts a user belongs to X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=a028a02f709081fb39d45f5648cde42b894a2b80;p=turbot Limit Turbot home display to hunts a user belongs to Membership is determined by membership in a hunt's primary slack channel. --- 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"))