From d6ed42b454193e5800f0a01e84dfb08bbd41e735 Mon Sep 17 00:00:00 2001 From: Raj Joshi Date: Mon, 30 Dec 2024 19:31:44 -0500 Subject: [PATCH 1/2] :wrench: chore: ga slack multi team linking --- src/sentry/features/temporary.py | 2 +- src/sentry/integrations/messaging/metrics.py | 1 - .../integrations/slack/webhooks/base.py | 2 -- .../integrations/slack/webhooks/command.py | 8 ------ .../slack/webhooks/commands/test_link_team.py | 26 ------------------- 5 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/sentry/features/temporary.py b/src/sentry/features/temporary.py index c46aa8b35c5f56..852a63f39e2983 100644 --- a/src/sentry/features/temporary.py +++ b/src/sentry/features/temporary.py @@ -424,7 +424,7 @@ def register_temporary_features(manager: FeatureManager): manager.add("organizations:slack-endpoint-regression-image", OrganizationFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False) manager.add("organizations:slack-function-regression-image", OrganizationFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False) # Enable linking to Slack alerts from multiple teams to a single channel - manager.add("organizations:slack-multiple-team-single-channel-linking", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False) + manager.add("organizations:slack-multiple-team-single-channel-linking", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False, default=True) manager.add("organizations:stacktrace-processing-caching", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, api_expose=False) # Enable SAML2 Single-logout manager.add("organizations:sso-saml2-slo", OrganizationFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False) diff --git a/src/sentry/integrations/messaging/metrics.py b/src/sentry/integrations/messaging/metrics.py index abbdb03a7f5aa5..82baec8eec3653 100644 --- a/src/sentry/integrations/messaging/metrics.py +++ b/src/sentry/integrations/messaging/metrics.py @@ -87,7 +87,6 @@ class MessageCommandHaltReason(StrEnum): # Team Linking LINK_FROM_CHANNEL = "link_from_channel" LINK_USER_FIRST = "link_user_first" - CHANNEL_ALREADY_LINKED = "channel_already_linked" TEAM_NOT_LINKED = "team_not_linked" INSUFFICIENT_ROLE = "insufficient_role" diff --git a/src/sentry/integrations/slack/webhooks/base.py b/src/sentry/integrations/slack/webhooks/base.py index f503adab1cb466..0699aa9e3aab93 100644 --- a/src/sentry/integrations/slack/webhooks/base.py +++ b/src/sentry/integrations/slack/webhooks/base.py @@ -136,7 +136,6 @@ class SlackCommandDispatcher(MessagingIntegrationCommandDispatcher[Response]): @property def TEAM_HALT_MAPPINGS(self) -> dict[str, MessageCommandHaltReason]: from sentry.integrations.slack.webhooks.command import ( - CHANNEL_ALREADY_LINKED_MESSAGE, INSUFFICIENT_ROLE_MESSAGE, LINK_FROM_CHANNEL_MESSAGE, LINK_USER_FIRST_MESSAGE, @@ -147,7 +146,6 @@ def TEAM_HALT_MAPPINGS(self) -> dict[str, MessageCommandHaltReason]: LINK_FROM_CHANNEL_MESSAGE: MessageCommandHaltReason.LINK_FROM_CHANNEL, LINK_USER_FIRST_MESSAGE: MessageCommandHaltReason.LINK_USER_FIRST, INSUFFICIENT_ROLE_MESSAGE: MessageCommandHaltReason.INSUFFICIENT_ROLE, - CHANNEL_ALREADY_LINKED_MESSAGE: MessageCommandHaltReason.CHANNEL_ALREADY_LINKED, TEAM_NOT_LINKED_MESSAGE: MessageCommandHaltReason.TEAM_NOT_LINKED, } diff --git a/src/sentry/integrations/slack/webhooks/command.py b/src/sentry/integrations/slack/webhooks/command.py index 957f2f545be530..575d983f72dd7e 100644 --- a/src/sentry/integrations/slack/webhooks/command.py +++ b/src/sentry/integrations/slack/webhooks/command.py @@ -6,7 +6,6 @@ from rest_framework.request import Request from rest_framework.response import Response -from sentry import features from sentry.api.api_owners import ApiOwner from sentry.api.api_publish_status import ApiPublishStatus from sentry.api.base import region_silo_endpoint @@ -35,7 +34,6 @@ "Link your Sentry team to this Slack channel! <{associate_url}|Link your team now> to receive " "notifications of issues in Sentry in Slack." ) -CHANNEL_ALREADY_LINKED_MESSAGE = "This channel already has a team linked to it." LINK_USER_FIRST_MESSAGE = ( "You must first link your identity to Sentry by typing /sentry link. Be aware that you " "must be an admin or higher in your Sentry organization or a team admin to link your team." @@ -101,12 +99,6 @@ def link_team(self, slack_request: SlackDMRequest) -> Response: has_valid_role = False for organization_membership in organization_memberships: - if not features.has( - "organizations:slack-multiple-team-single-channel-linking", - organization_membership.organization, - ) and is_team_linked_to_channel(organization_membership.organization, slack_request): - return self.reply(slack_request, CHANNEL_ALREADY_LINKED_MESSAGE) - if is_valid_role(organization_membership) or is_team_admin(organization_membership): has_valid_role = True diff --git a/tests/sentry/integrations/slack/webhooks/commands/test_link_team.py b/tests/sentry/integrations/slack/webhooks/commands/test_link_team.py index 3f366d4436c31e..22dfc7a97bc90b 100644 --- a/tests/sentry/integrations/slack/webhooks/commands/test_link_team.py +++ b/tests/sentry/integrations/slack/webhooks/commands/test_link_team.py @@ -5,7 +5,6 @@ from rest_framework import status from sentry.integrations.slack.webhooks.command import ( - CHANNEL_ALREADY_LINKED_MESSAGE, INSUFFICIENT_ROLE_MESSAGE, LINK_FROM_CHANNEL_MESSAGE, LINK_USER_FIRST_MESSAGE, @@ -15,7 +14,6 @@ from sentry.silo.base import SiloMode from sentry.testutils.asserts import assert_slo_metric from sentry.testutils.helpers import get_response_text, link_user -from sentry.testutils.helpers.features import with_feature from sentry.testutils.silo import assume_test_silo_mode from tests.sentry.integrations.slack.webhooks.commands import SlackCommandsTest @@ -53,30 +51,6 @@ def test_link_another_team_to_channel(self, mock_record): """ self.link_team() - response = self.get_slack_response( - { - "text": "link team", - "team_id": self.external_id, - "user_id": self.slack_id, - "channel_name": self.channel_name, - "channel_id": self.channel_id, - } - ) - data = orjson.loads(response.content) - assert CHANNEL_ALREADY_LINKED_MESSAGE in get_response_text(data) - - assert_slo_metric(mock_record, EventLifecycleOutcome.HALTED) - - @with_feature("organizations:slack-multiple-team-single-channel-linking") - @patch("sentry.integrations.utils.metrics.EventLifecycle.record_event") - @responses.activate - def test_link_another_team_to_channel_with_flag(self, mock_record): - """ - Test that we block a user who tries to link a second team to a - channel that already has a team linked to it. - """ - self.link_team() - response = self.get_slack_response( { "text": "link team", From 100da8f29d3d9e6b8379be9d2efce3c6c37de718 Mon Sep 17 00:00:00 2001 From: Raj Joshi Date: Tue, 31 Dec 2024 09:26:00 -0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20chore:=20remove=20slack=20mu?= =?UTF-8?q?lti=20team=20linking=20ff=20handler=20(#82757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sentry/features/temporary.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sentry/features/temporary.py b/src/sentry/features/temporary.py index 852a63f39e2983..7a5e2efe11ef78 100644 --- a/src/sentry/features/temporary.py +++ b/src/sentry/features/temporary.py @@ -423,8 +423,6 @@ def register_temporary_features(manager: FeatureManager): # Add regression chart as image to slack message manager.add("organizations:slack-endpoint-regression-image", OrganizationFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False) manager.add("organizations:slack-function-regression-image", OrganizationFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False) - # Enable linking to Slack alerts from multiple teams to a single channel - manager.add("organizations:slack-multiple-team-single-channel-linking", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False, default=True) manager.add("organizations:stacktrace-processing-caching", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, api_expose=False) # Enable SAML2 Single-logout manager.add("organizations:sso-saml2-slo", OrganizationFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False)