Skip to content

Commit

Permalink
🔧 chore: GA slack multi team linking (#82746)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrajjoshi authored and andrewshie-sentry committed Jan 2, 2025
1 parent 74194ce commit 74ee2d6
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 39 deletions.
2 changes: 0 additions & 2 deletions src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)
Expand Down
1 change: 0 additions & 1 deletion src/sentry/integrations/messaging/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 0 additions & 2 deletions src/sentry/integrations/slack/webhooks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
}

Expand Down
8 changes: 0 additions & 8 deletions src/sentry/integrations/slack/webhooks/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 74ee2d6

Please sign in to comment.