Skip to content
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

Conversation

WilliamBergamin
Copy link
Contributor

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 [ ])

@codecov
Copy link

codecov bot commented Oct 5, 2022

Codecov Report

Merging #1615 (2b5e498) into main (be8a041) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@            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              
Impacted Files Coverage Δ
src/App.ts 84.33% <100.00%> (+0.21%) ⬆️

📣 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) {
Copy link
Member

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 = (
Copy link
Member

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

Copy link
Contributor Author

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 🥇

Copy link
Member

@srajiang srajiang left a 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 (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const bodyAsActionOrOptionsOrOrShortcut = body as (
const bodyAsActionOrOptionsOrShortcut = body as (

Copy link
Contributor Author

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return parseTeamId(bodyAsActionOrOptionsOrOrShortcut);
return parseTeamId(bodyAsActionOrOptionsOrShortcut);

@seratch seratch added the bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented label Oct 5, 2022
@seratch seratch added this to the 3.12.2 milestone Oct 5, 2022
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants