]> git.cworth.org Git - turbot/commitdiff
Limit Turbot home display to hunts a user belongs to
authorCarl Worth <cworth@cworth.org>
Fri, 23 Oct 2020 14:48:55 +0000 (07:48 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 23 Oct 2020 14:48:55 +0000 (07:48 -0700)
Membership is determined by membership in a hunt's primary slack channel.

turbot/events.py

index 0a1eb099e8d3744782bd665be10f11ac03849799..1b15f0cdd32b918c141ab13466b74a0de208c8d8 100644 (file)
@@ -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"))