@@ -62,14 +62,14 @@ def _fetch_parent_notification_message_for_incident(
62
62
alert_context : AlertContext ,
63
63
notification_context : NotificationContext ,
64
64
metric_issue_context : MetricIssueContext ,
65
+ repository : MetricAlertNotificationMessageRepository ,
65
66
) -> MetricAlertNotificationMessage | None :
66
67
parent_notification_message = None
67
68
68
69
with MessagingInteractionEvent (
69
70
interaction_type = MessagingInteractionType .GET_PARENT_NOTIFICATION ,
70
71
spec = SlackMessagingSpec (),
71
72
).capture () as lifecycle :
72
- repository : MetricAlertNotificationMessageRepository = get_default_metric_alert_repository ()
73
73
# Only grab the parent notification message for thread use if the feature is on
74
74
# Otherwise, leave it empty, and it will not create a thread
75
75
if OrganizationOption .objects .get_value (
@@ -139,6 +139,7 @@ def _send_notification(
139
139
thread_ts : str | None ,
140
140
reply_broadcast : bool ,
141
141
notification_message_object : NewMetricAlertNotificationMessage ,
142
+ repository : MetricAlertNotificationMessageRepository ,
142
143
) -> bool :
143
144
with MessagingInteractionEvent (
144
145
interaction_type = MessagingInteractionType .SEND_INCIDENT_ALERT_NOTIFICATION ,
@@ -182,12 +183,13 @@ def _send_notification(
182
183
183
184
notification_message_object .message_identifier = str (ts ) if ts is not None else None
184
185
185
- _save_notification_message (notification_message_object )
186
+ _save_notification_message (notification_message_object , repository )
186
187
return True
187
188
188
189
189
190
def _save_notification_message (
190
191
notification_message_object : NewMetricAlertNotificationMessage ,
192
+ repository : MetricAlertNotificationMessageRepository ,
191
193
) -> None :
192
194
try :
193
195
repository = get_default_metric_alert_repository ()
@@ -248,11 +250,14 @@ def send_incident_alert_notification(
248
250
notification_uuid = notification_uuid ,
249
251
)
250
252
253
+ repository = get_default_metric_alert_repository ()
254
+
251
255
parent_notification_message = _fetch_parent_notification_message_for_incident (
252
256
organization = organization ,
253
257
alert_context = alert_context ,
254
258
notification_context = notification_context ,
255
259
metric_issue_context = incident_context ,
260
+ repository = repository ,
256
261
)
257
262
258
263
new_notification_message_object = NewMetricAlertNotificationMessage (
@@ -285,6 +290,7 @@ def send_incident_alert_notification(
285
290
thread_ts = thread_ts ,
286
291
reply_broadcast = reply_broadcast ,
287
292
notification_message_object = new_notification_message_object ,
293
+ repository = repository ,
288
294
)
289
295
290
296
return success
0 commit comments