Skip to content

Commit f0ef1c3

Browse files
authored
Fix #763 by improving the suggestion logging for view_closed patterns (#766)
* Fix #763 by improving the suggestion logging for view_closed patterns
1 parent 3b05b5f commit f0ef1c3

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

slack_bolt/logger/messages.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
is_options,
1111
is_shortcut,
1212
is_slash_command,
13-
is_view,
13+
is_view_submission,
14+
is_view_closed,
1415
is_workflow_step_edit,
1516
is_workflow_step_save,
1617
is_workflow_step_execute,
@@ -241,13 +242,24 @@ def warning_unhandled_request( # type: ignore
241242
logger.info(body)
242243
""",
243244
)
244-
if is_view(req.body):
245+
if is_view_submission(req.body):
245246
# @app.view
246247
return _build_unhandled_request_suggestion(
247248
default_message,
248249
f"""
249250
@app.view("{req.body.get('view', {}).get('callback_id', 'modal-view-id')}")
250-
{'async ' if is_async else ''}def handle_view_events(ack, body, logger):
251+
{'async ' if is_async else ''}def handle_view_submission_events(ack, body, logger):
252+
{'await ' if is_async else ''}ack()
253+
logger.info(body)
254+
""",
255+
)
256+
if is_view_closed(req.body):
257+
# @app.view
258+
return _build_unhandled_request_suggestion(
259+
default_message,
260+
f"""
261+
@app.view_closed("{req.body.get('view', {}).get('callback_id', 'modal-view-id')}")
262+
{'async ' if is_async else ''}def handle_view_closed_events(ack, body, logger):
251263
{'await ' if is_async else ''}ack()
252264
logger.info(body)
253265
""",

tests/slack_bolt/logger/test_unmatched_suggestions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_view(self):
153153
[Suggestion] You can handle this type of event with the following listener function:
154154
155155
@app.view("view-id")
156-
def handle_view_events(ack, body, logger):
156+
def handle_view_submission_events(ack, body, logger):
157157
ack()
158158
logger.info(body)
159159
"""
@@ -171,8 +171,8 @@ def handle_view_events(ack, body, logger):
171171
---
172172
[Suggestion] You can handle this type of event with the following listener function:
173173
174-
@app.view("view-id")
175-
def handle_view_events(ack, body, logger):
174+
@app.view_closed("view-id")
175+
def handle_view_closed_events(ack, body, logger):
176176
ack()
177177
logger.info(body)
178178
"""

tests/slack_bolt_async/logger/test_unmatched_suggestions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_view(self):
153153
[Suggestion] You can handle this type of event with the following listener function:
154154
155155
@app.view("view-id")
156-
async def handle_view_events(ack, body, logger):
156+
async def handle_view_submission_events(ack, body, logger):
157157
await ack()
158158
logger.info(body)
159159
"""
@@ -171,8 +171,8 @@ async def handle_view_events(ack, body, logger):
171171
---
172172
[Suggestion] You can handle this type of event with the following listener function:
173173
174-
@app.view("view-id")
175-
async def handle_view_events(ack, body, logger):
174+
@app.view_closed("view-id")
175+
async def handle_view_closed_events(ack, body, logger):
176176
await ack()
177177
logger.info(body)
178178
"""

0 commit comments

Comments
 (0)