Skip to content

Commit

Permalink
feat(team-workflow): Update Slack linking message to include workflow…
Browse files Browse the repository at this point in the history
… alerts (#58875)

This PR updates the Slack message received upon linking a team so that
it includes "workflow alerts" (feature flagged until Team Workflow
Notifications is GA'd).

Closes #58874.
  • Loading branch information
isabellaenriquez authored Oct 27, 2023
1 parent 6ad6766 commit cb8d0f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/sentry/integrations/slack/views/link_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.utils.decorators import method_decorator
from rest_framework.request import Request

from sentry import analytics
from sentry import analytics, features
from sentry.models.integrations.external_actor import ExternalActor
from sentry.models.integrations.integration import Integration
from sentry.models.organizationmember import OrganizationMember
Expand All @@ -33,9 +33,7 @@
ALREADY_LINKED_TITLE = "Already linked"
ALREADY_LINKED_MESSAGE = "The {slug} team has already been linked to a Slack channel."
SUCCESS_LINKED_TITLE = "Team linked"
SUCCESS_LINKED_MESSAGE = (
"The {slug} team will now receive issue alert notifications in the {channel_name} channel."
)
SUCCESS_LINKED_MESSAGE = "The {slug} team will now receive issue alert{workflow_addon} notifications in the {channel_name} channel."


def build_team_linking_url(
Expand Down Expand Up @@ -202,7 +200,13 @@ def handle(self, request: Request, signed_params: str) -> HttpResponse:
actor=RpcActor(id=team.id, actor_type=ActorType.TEAM),
organization_id_for_team=team.organization_id,
)
message = SUCCESS_LINKED_MESSAGE.format(slug=team.slug, channel_name=channel_name)
message = SUCCESS_LINKED_MESSAGE.format(
slug=team.slug,
workflow_addon=" and workflow"
if features.has("organizations:team-workflow-notifications", team.organization)
else "",
channel_name=channel_name,
)
integration_service.send_message(
integration_id=integration.id,
organization_id=team.organization_id,
Expand Down
14 changes: 14 additions & 0 deletions tests/sentry/integrations/slack/test_link_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from sentry.silo import SiloMode
from sentry.testutils.cases import TestCase
from sentry.testutils.helpers import add_identity, get_response_text, install_slack, link_team
from sentry.testutils.helpers.features import with_feature
from sentry.testutils.silo import assume_test_silo_mode, region_silo_test
from sentry.types.integrations import ExternalProviders
from sentry.utils import json
Expand Down Expand Up @@ -228,6 +229,19 @@ def test_link_team_multiple_organizations(self):
)
assert len(external_actors) == 1

@responses.activate
@with_feature("organizations:team-workflow-notifications")
def test_message_includes_workflow(self):
self.get_success_response(data={"team": self.team.id})
external_actors = self.get_linked_teams()

assert len(responses.calls) >= 1
data = json.loads(str(responses.calls[0].request.body.decode("utf-8")))
assert (
f"The {self.team.slug} team will now receive issue alert and workflow notifications in the {external_actors[0].external_name} channel."
in get_response_text(data)
)


@region_silo_test(stable=True)
class SlackIntegrationUnlinkTeamTest(SlackIntegrationLinkTeamTestBase):
Expand Down

0 comments on commit cb8d0f7

Please sign in to comment.