Skip to content

Commit f6a1174

Browse files
committed
🔧 chore: don't pass repo around
1 parent 3d2a416 commit f6a1174

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/sentry/integrations/slack/utils/notifications.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ def _fetch_parent_notification_message_for_incident(
6262
alert_context: AlertContext,
6363
notification_context: NotificationContext,
6464
metric_issue_context: MetricIssueContext,
65+
repository: MetricAlertNotificationMessageRepository,
6566
) -> MetricAlertNotificationMessage | None:
6667
parent_notification_message = None
6768

6869
with MessagingInteractionEvent(
6970
interaction_type=MessagingInteractionType.GET_PARENT_NOTIFICATION,
7071
spec=SlackMessagingSpec(),
7172
).capture() as lifecycle:
72-
repository: MetricAlertNotificationMessageRepository = get_default_metric_alert_repository()
7373
# Only grab the parent notification message for thread use if the feature is on
7474
# Otherwise, leave it empty, and it will not create a thread
7575
if OrganizationOption.objects.get_value(
@@ -139,6 +139,7 @@ def _send_notification(
139139
thread_ts: str | None,
140140
reply_broadcast: bool,
141141
notification_message_object: NewMetricAlertNotificationMessage,
142+
repository: MetricAlertNotificationMessageRepository,
142143
) -> bool:
143144
with MessagingInteractionEvent(
144145
interaction_type=MessagingInteractionType.SEND_INCIDENT_ALERT_NOTIFICATION,
@@ -182,12 +183,13 @@ def _send_notification(
182183

183184
notification_message_object.message_identifier = str(ts) if ts is not None else None
184185

185-
_save_notification_message(notification_message_object)
186+
_save_notification_message(notification_message_object, repository)
186187
return True
187188

188189

189190
def _save_notification_message(
190191
notification_message_object: NewMetricAlertNotificationMessage,
192+
repository: MetricAlertNotificationMessageRepository,
191193
) -> None:
192194
try:
193195
repository = get_default_metric_alert_repository()
@@ -248,11 +250,14 @@ def send_incident_alert_notification(
248250
notification_uuid=notification_uuid,
249251
)
250252

253+
repository = get_default_metric_alert_repository()
254+
251255
parent_notification_message = _fetch_parent_notification_message_for_incident(
252256
organization=organization,
253257
alert_context=alert_context,
254258
notification_context=notification_context,
255259
metric_issue_context=incident_context,
260+
repository=repository,
256261
)
257262

258263
new_notification_message_object = NewMetricAlertNotificationMessage(
@@ -285,6 +290,7 @@ def send_incident_alert_notification(
285290
thread_ts=thread_ts,
286291
reply_broadcast=reply_broadcast,
287292
notification_message_object=new_notification_message_object,
293+
repository=repository,
288294
)
289295

290296
return success

0 commit comments

Comments
 (0)