File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed
slack_bolt/listener_matcher Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -292,7 +292,7 @@ def func(body: Dict[str, Any]) -> bool:
292292 return workflow_step_edit (constraints ["callback_id" ], asyncio )
293293
294294 raise BoltError (f"type: { action_type } is unsupported" )
295- elif "action_id" in constraints :
295+ elif "action_id" in constraints or "block_id" in constraints :
296296 # The default value is "block_actions"
297297 return block_action (constraints , asyncio )
298298
@@ -313,8 +313,11 @@ def _block_action(
313313 elif isinstance (constraints , dict ):
314314 # block_id matching is optional
315315 block_id : Optional [Union [str , Pattern ]] = constraints .get ("block_id" )
316+ action_id : Optional [Union [str , Pattern ]] = constraints .get ("action_id" )
317+ if block_id is None and action_id is None :
318+ return False
316319 block_id_matched = block_id is None or _matches (block_id , action .get ("block_id" ))
317- action_id_matched = _matches (constraints [ " action_id" ] , action [ "action_id" ] )
320+ action_id_matched = action_id is None or _matches (action_id , action . get ( "action_id" ) )
318321 return block_id_matched and action_id_matched
319322
320323
Original file line number Diff line number Diff line change @@ -109,6 +109,15 @@ def test_default_type_no_block_id(self):
109109 assert response .status == 200
110110 assert_auth_test_count (self , 1 )
111111
112+ def test_default_type_no_action_id (self ):
113+ app = App (client = self .web_client , signing_secret = self .signing_secret )
114+ app .action ({"block_id" : "b" })(simple_listener )
115+
116+ request = self .build_valid_request ()
117+ response = app .dispatch (request )
118+ assert response .status == 200
119+ assert_auth_test_count (self , 1 )
120+
112121 def test_default_type_and_unmatched_block_id (self ):
113122 app = App (client = self .web_client , signing_secret = self .signing_secret )
114123 app .action ({"action_id" : "a" , "block_id" : "bbb" })(simple_listener )
Original file line number Diff line number Diff line change @@ -114,6 +114,19 @@ async def test_default_type_no_block_id(self):
114114 assert response .status == 200
115115 await assert_auth_test_count_async (self , 1 )
116116
117+ @pytest .mark .asyncio
118+ async def test_default_type_no_action_id (self ):
119+ app = AsyncApp (
120+ client = self .web_client ,
121+ signing_secret = self .signing_secret ,
122+ )
123+ app .action ({"block_id" : "b" })(simple_listener )
124+
125+ request = self .build_valid_request ()
126+ response = await app .async_dispatch (request )
127+ assert response .status == 200
128+ await assert_auth_test_count_async (self , 1 )
129+
117130 @pytest .mark .asyncio
118131 async def test_default_type_unmatched_block_id (self ):
119132 app = AsyncApp (
You can’t perform that action at this time.
0 commit comments