Fix context.team_id for view interactions in a Slack Connect channel#1615
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1615 +/- ##
==========================================
+ Coverage 82.01% 82.09% +0.07%
==========================================
Files 18 18
Lines 1496 1502 +6
Branches 436 437 +1
==========================================
+ Hits 1227 1233 +6
Misses 172 172
Partials 97 97
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
| if (type === IncomingEventType.ViewAction) { | ||
| const bodyAsView = body as SlackViewMiddlewareArgs['body']; | ||
|
|
||
| if (bodyAsView.view.app_installed_team_id) { |
There was a problem hiding this comment.
Nice! Can we also add a comment for future eyes about when this condition is met, since it's a little nuanced? Maybe mirroring what Kaz has added in his PR
| return (body as SlackCommandMiddlewareArgs['body']).team_id; | ||
| } | ||
|
|
||
| const parseTeamId = ( |
There was a problem hiding this comment.
Thanks for decomposing this out into its own function! Slowly but surely, the horrible mess that is App.ts will be reformed :P
There was a problem hiding this comment.
No problem, we will eventually get there 🥇
srajiang
left a comment
There was a problem hiding this comment.
Looking good - left some comments!
src/App.ts
Outdated
| type === IncomingEventType.Shortcut | ||
| ) { | ||
| const bodyAsActionOrOptionsOrViewActionOrShortcut = body as ( | ||
| const bodyAsActionOrOptionsOrOrShortcut = body as ( |
There was a problem hiding this comment.
| const bodyAsActionOrOptionsOrOrShortcut = body as ( | |
| const bodyAsActionOrOptionsOrShortcut = body as ( |
There was a problem hiding this comment.
Good catch 💯
src/App.ts
Outdated
|
|
||
| // This is the only place where this function might return undefined | ||
| return bodyAsActionOrOptionsOrViewActionOrShortcut.user.team_id; | ||
| return parseTeamId(bodyAsActionOrOptionsOrOrShortcut); |
There was a problem hiding this comment.
| return parseTeamId(bodyAsActionOrOptionsOrOrShortcut); | |
| return parseTeamId(bodyAsActionOrOptionsOrShortcut); |
Summary
This pull request resolves a bug where context.team_id can be invalid for view interactions (view_submission / view_closed) in a Slack Connect channel, which was reported at #1614
Requirements (place an
xin each[ ])