Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sentry/integrations/discord/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def send_notification(
except ApiError as e:
translate_discord_api_error(e)

def send_notification_with_threading(
def send_notification_with_response(
self,
target: IntegrationNotificationTarget,
payload: DiscordRenderable,
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/integrations/msteams/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def send_notification(
client = self.get_client()
client.send_card(conversation_id=target.resource_id, card=payload)

def send_notification_with_threading(
def send_notification_with_response(
self,
target: IntegrationNotificationTarget,
payload: AdaptiveCard,
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/integrations/slack/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def send_notification(
translate_slack_api_error(e)
return {}

def send_notification_with_threading(
def send_notification_with_response(
self,
target: IntegrationNotificationTarget,
payload: SlackRenderable,
Expand Down
53 changes: 53 additions & 0 deletions src/sentry/integrations/slack/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
from sentry.models.group import Group
from sentry.models.options.organization_option import OrganizationOption
from sentry.notifications.additional_attachment_manager import get_additional_attachment
from sentry.notifications.models.notificationthread import (
NotificationThread,
NotificationThreadObjectType,
)
from sentry.notifications.notifications.activity.archive import ArchiveActivityNotification
from sentry.notifications.notifications.activity.assigned import AssignedActivityNotification
from sentry.notifications.notifications.activity.base import GroupActivityNotification
Expand All @@ -58,6 +62,8 @@
from sentry.notifications.notifications.activity.unassigned import UnassignedActivityNotification
from sentry.notifications.notifications.activity.unresolved import UnresolvedActivityNotification
from sentry.notifications.notifications.base import BaseNotification
from sentry.notifications.platform.rollout import NotificationRolloutService
from sentry.notifications.platform.types import SLACK_PROVIDERS, NotificationSource
from sentry.notifications.utils.open_period import open_period_start_for_group
from sentry.silo.base import SiloMode
from sentry.types.activity import ActivityType
Expand Down Expand Up @@ -249,6 +255,25 @@ def _notify_all_threads_for_activity(
group_ids=[group.id],
)

# Also query platform threads for issue alerts sent via notification platform. Only orgs in
# a platform rollout tier have them, so skip the query for everyone else. This checks the
# tier, not the per-send random rollout rate, so replies reach every existing thread.
platform_threads = NotificationThread.objects.none()
if NotificationRolloutService(organization=group.organization).has_feature_flag_access():
platform_threads = NotificationThread.objects.filter(
object_type=NotificationThreadObjectType.GROUP,
object_id=group.id,
key_type=NotificationSource.ISSUE.value,
provider_key__in=SLACK_PROVIDERS,
)
Comment thread
shayna-ch marked this conversation as resolved.
if use_open_period_start:
# The platform thread key stores the open period start as an ISO string
platform_threads = platform_threads.filter(
key_data__open_period_start=(
open_period_start.isoformat() if open_period_start else None
)
)

# We don't wrap this in a lifecycle because _handle_parent_notification is already wrapped in a lifecycle
parent_notification_count = 0
for parent_notification in parent_notifications:
Expand Down Expand Up @@ -307,6 +332,34 @@ def _notify_all_threads_for_activity(
},
)

# Send to platform threads
for platform_thread in platform_threads:
Comment thread
hobzcalvin marked this conversation as resolved.
with MessagingInteractionEvent(
interaction_type=MessagingInteractionType.SEND_ACTIVITY_NOTIFICATION,
spec=SlackMessagingSpec(),
).capture() as lifecycle:
lifecycle.add_extras(
{
"activity_id": activity.id,
"platform_thread_id": platform_thread.id,
"integration_id": client.integration_id,
"group_id": group.id,
"project_id": activity.project.id,
}
)
Comment thread
shayna-ch marked this conversation as resolved.
try:
self._send_notification_to_slack_channel(
channel_id=platform_thread.target_id,
message_identifier=platform_thread.thread_identifier,
notification_to_send=notification_to_send,
client=client,
)
except Exception as err:
if isinstance(err, SlackApiError):
record_lifecycle_termination_level(lifecycle, err)
else:
lifecycle.record_failure(err)

def _get_channel_id_from_parent_notification_notification_action(
self,
parent_notification: NotificationActionNotificationMessage,
Expand Down
Loading
Loading