1
1
import logging
2
2
from datetime import datetime
3
3
4
- from sentry .eventstore .models import GroupEvent
5
4
from sentry .integrations .repository import get_default_notification_action_repository
6
5
from sentry .integrations .repository .base import NotificationMessageValidationError
7
6
from sentry .integrations .repository .notification_action import (
8
7
NewNotificationActionNotificationMessage ,
8
+ NotificationActionNotificationMessage ,
9
9
NotificationActionNotificationMessageRepository ,
10
10
)
11
11
from sentry .integrations .utils .metrics import EventLifecycle
12
+ from sentry .models .group import Group
12
13
from sentry .models .options .organization_option import OrganizationOption
13
14
from sentry .models .organization import Organization
14
15
from sentry .workflow_engine .models .action import Action
@@ -46,16 +47,15 @@ def _save_notification_action_message(
46
47
pass
47
48
48
49
@classmethod
49
- def _get_notification_action_thread_ts (
50
+ def _get_notification_action_for_notification_action (
50
51
cls ,
51
52
organization : Organization ,
52
53
lifecycle : EventLifecycle ,
53
54
action : Action ,
54
- event : GroupEvent ,
55
+ group : Group ,
55
56
open_period_start : datetime | None ,
56
- new_notification_message_object : NewNotificationActionNotificationMessage ,
57
57
thread_option_default : bool ,
58
- ) -> str | None :
58
+ ) -> NotificationActionNotificationMessage | None :
59
59
"""Find the thread in which to post a notification action notification as a reply.
60
60
61
61
Return None to post the notification as a top-level message.
@@ -69,23 +69,18 @@ def _get_notification_action_thread_ts(
69
69
):
70
70
return None
71
71
72
+ parent_notification_message : NotificationActionNotificationMessage | None = None
72
73
try :
73
74
action_repository : NotificationActionNotificationMessageRepository = (
74
75
get_default_notification_action_repository ()
75
76
)
76
77
parent_notification_message = action_repository .get_parent_notification_message (
77
78
action = action ,
78
- group = event . group ,
79
+ group = group ,
79
80
open_period_start = open_period_start ,
80
81
)
81
82
except Exception as e :
82
83
lifecycle .record_halt (e )
83
84
return None
84
85
85
- if parent_notification_message is None :
86
- return None
87
-
88
- new_notification_message_object .parent_notification_message_id = (
89
- parent_notification_message .id
90
- )
91
- return parent_notification_message .message_identifier
86
+ return parent_notification_message
0 commit comments