-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix context.team_id for view interactions in a Slack Connect channel #1615
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -1368,29 +1368,43 @@ function buildSource<IsEnterpriseInstall extends boolean>( | |||
return (body as SlackCommandMiddlewareArgs['body']).team_id; | |||
} | |||
|
|||
const parseTeamId = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, we will eventually get there 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const bodyAsActionOrOptionsOrOrShortcut = body as ( | |
const bodyAsActionOrOptionsOrShortcut = body as ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return parseTeamId(bodyAsActionOrOptionsOrOrShortcut); | |
return parseTeamId(bodyAsActionOrOptionsOrShortcut); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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
x
in each[ ]
)