Skip to content

Commit 7600378

Browse files
🔧 chore: fix slack webhook commands endpoint typing (#89579)
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 6218eb7 commit 7600378

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ module = [
133133
"sentry.integrations.pagerduty.actions.form",
134134
"sentry.integrations.pipeline",
135135
"sentry.integrations.slack.message_builder.notifications.issues",
136-
"sentry.integrations.slack.webhooks.command",
137136
"sentry.integrations.slack.webhooks.event",
138137
"sentry.integrations.utils.sync",
139138
"sentry.integrations.vsts.integration",

src/sentry/integrations/slack/views/unlink_team.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from sentry.integrations.messaging.linkage import UnlinkTeamView
44
from sentry.integrations.models.integration import Integration
5+
from sentry.integrations.services.integration import RpcIntegration
56
from sentry.integrations.slack.views.linkage import SlackLinkageView
67
from sentry.web.frontend.base import region_silo_view
78

@@ -15,8 +16,8 @@
1516

1617

1718
def build_team_unlinking_url(
18-
integration: Integration,
19-
organization_id: str,
19+
integration: Integration | RpcIntegration,
20+
organization_id: int,
2021
slack_id: str,
2122
channel_id: str,
2223
channel_name: str,

src/sentry/integrations/slack/webhooks/command.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
INSUFFICIENT_ROLE_MESSAGE = (
4141
"You must be a Sentry organization admin/manager/owner or a team admin to link or unlink teams."
4242
)
43+
NO_USER_ID_MESSAGE = "Could not identify your Slack user ID. Please try again."
44+
NO_CHANNEL_ID_MESSAGE = "Could not identify the Slack channel ID. Please try again."
4345

4446

4547
def is_team_linked_to_channel(organization: Organization, slack_request: SlackDMRequest) -> bool:
@@ -97,6 +99,12 @@ def link_team(self, slack_request: SlackDMRequest) -> Response:
9799
if not has_valid_role:
98100
return self.reply(slack_request, INSUFFICIENT_ROLE_MESSAGE)
99101

102+
if not slack_request.user_id:
103+
return self.reply(slack_request, NO_USER_ID_MESSAGE)
104+
105+
if not slack_request.channel_id:
106+
return self.reply(slack_request, NO_CHANNEL_ID_MESSAGE)
107+
100108
associate_url = build_team_linking_url(
101109
integration=integration,
102110
slack_id=slack_request.user_id,
@@ -131,6 +139,12 @@ def unlink_team(self, slack_request: SlackDMRequest) -> Response:
131139
if not is_valid_role(found) and not is_team_admin(found):
132140
return self.reply(slack_request, INSUFFICIENT_ROLE_MESSAGE)
133141

142+
if not slack_request.user_id:
143+
return self.reply(slack_request, NO_USER_ID_MESSAGE)
144+
145+
if not slack_request.channel_id:
146+
return self.reply(slack_request, NO_CHANNEL_ID_MESSAGE)
147+
134148
associate_url = build_team_unlinking_url(
135149
integration=integration,
136150
organization_id=found.organization.id,

0 commit comments

Comments
 (0)