|
40 | 40 | INSUFFICIENT_ROLE_MESSAGE = (
|
41 | 41 | "You must be a Sentry organization admin/manager/owner or a team admin to link or unlink teams."
|
42 | 42 | )
|
| 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." |
43 | 45 |
|
44 | 46 |
|
45 | 47 | def is_team_linked_to_channel(organization: Organization, slack_request: SlackDMRequest) -> bool:
|
@@ -97,6 +99,12 @@ def link_team(self, slack_request: SlackDMRequest) -> Response:
|
97 | 99 | if not has_valid_role:
|
98 | 100 | return self.reply(slack_request, INSUFFICIENT_ROLE_MESSAGE)
|
99 | 101 |
|
| 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 | + |
100 | 108 | associate_url = build_team_linking_url(
|
101 | 109 | integration=integration,
|
102 | 110 | slack_id=slack_request.user_id,
|
@@ -131,6 +139,12 @@ def unlink_team(self, slack_request: SlackDMRequest) -> Response:
|
131 | 139 | if not is_valid_role(found) and not is_team_admin(found):
|
132 | 140 | return self.reply(slack_request, INSUFFICIENT_ROLE_MESSAGE)
|
133 | 141 |
|
| 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 | + |
134 | 148 | associate_url = build_team_unlinking_url(
|
135 | 149 | integration=integration,
|
136 | 150 | organization_id=found.organization.id,
|
|
0 commit comments