diff --git a/docs/sources/oncall-api-reference/escalation_policies.md b/docs/sources/oncall-api-reference/escalation_policies.md index 465b7f2540..d50cf7313b 100644 --- a/docs/sources/oncall-api-reference/escalation_policies.md +++ b/docs/sources/oncall-api-reference/escalation_policies.md @@ -40,22 +40,22 @@ The above command returns JSON structured in the following way: } ``` -| Parameter | Required | Description | -| ---------------------------------- |:----------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `escalation_chain_id` | Yes | Each escalation policy is assigned to a specific escalation chain. | -| `position` | Optional | Escalation policies execute one after another starting from `position=0`. `Position=-1` will put the escalation policy to the end of the list. A new escalation policy created with a position of an existing escalation policy will move the old one (and all following) down in the list. | -| `type` | Yes | One of: `wait`, `notify_persons`, `notify_person_next_each_time`, `notify_on_call_from_schedule`, `notify_user_group`, `trigger_webhook`, `resolve`, `notify_whole_channel`, `notify_if_time_from_to`, `declare_incident`. | -| `important` | Optional | Default is `false`. Will assign "important" to personal notification rules if `true`. This can be used to distinguish alerts on which you want to be notified immediately by phone. Applicable for types `notify_persons`, `notify_team_members`, `notify_on_call_from_schedule`, and `notify_user_group`. | -| `duration` | If type = `wait` | The duration, in seconds, when type `wait` is chosen. Valid values are any number of seconds in the inclusive range `60 to 86400`. | -| `action_to_trigger` | If type = `trigger_webhook` | ID of a webhook. | -| `group_to_notify` | If type = `notify_user_group` | ID of a `User Group`. | -| `persons_to_notify` | If type = `notify_persons` | List of user IDs. | -| `persons_to_notify_next_each_time` | If type = `notify_person_next_each_time` | List of user IDs. | -| `notify_on_call _from_schedule` | If type = `notify_on_call_from_schedule` | ID of a Schedule. | -| `notify_if_time_from` | If type = `notify_if_time_from_to` | UTC time represents the beginning of the time period, for example `09:00:00Z`. | -| `notify_if_time_to` | If type = `notify_if_time_from_to` | UTC time represents the end of the time period, for example `18:00:00Z`. | -| `team_to_notify` | If type = `notify_team_members` | ID of a team. | -| `severity` | If type = `declare_incident` | Severity of the incident. | +| Parameter | Required | Description | +| ---------------------------------- |:----------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `escalation_chain_id` | Yes | Each escalation policy is assigned to a specific escalation chain. | +| `position` | Optional | Escalation policies execute one after another starting from `position=0`. `Position=-1` will put the escalation policy to the end of the list. A new escalation policy created with a position of an existing escalation policy will move the old one (and all following) down in the list. | +| `type` | Yes | One of: `wait`, `notify_persons`, `notify_person_next_each_time`, `notify_on_call_from_schedule`, `notify_user_group`, `trigger_webhook`, `resolve`, `notify_whole_channel`, `notify_if_time_from_to`, `declare_incident`. | +| `important` | Optional | Default is `false`. Will assign "important" to personal notification rules if `true`. This can be used to distinguish alerts on which you want to be notified immediately by phone. Applicable for types `notify_persons`, `notify_person_next_each_time`, `notify_team_members`, `notify_on_call_from_schedule`, and `notify_user_group`. | +| `duration` | If type = `wait` | The duration, in seconds, when type `wait` is chosen. Valid values are any number of seconds in the inclusive range `60 to 86400`. | +| `action_to_trigger` | If type = `trigger_webhook` | ID of a webhook. | +| `group_to_notify` | If type = `notify_user_group` | ID of a `User Group`. | +| `persons_to_notify` | If type = `notify_persons` | List of user IDs. | +| `persons_to_notify_next_each_time` | If type = `notify_person_next_each_time` | List of user IDs. | +| `notify_on_call _from_schedule` | If type = `notify_on_call_from_schedule` | ID of a Schedule. | +| `notify_if_time_from` | If type = `notify_if_time_from_to` | UTC time represents the beginning of the time period, for example `09:00:00Z`. | +| `notify_if_time_to` | If type = `notify_if_time_from_to` | UTC time represents the end of the time period, for example `18:00:00Z`. | +| `team_to_notify` | If type = `notify_team_members` | ID of a team. | +| `severity` | If type = `declare_incident` | Severity of the incident. | **HTTP request** diff --git a/engine/apps/alerts/escalation_snapshot/snapshot_classes/escalation_policy_snapshot.py b/engine/apps/alerts/escalation_snapshot/snapshot_classes/escalation_policy_snapshot.py index 1811e2e9aa..ede9e00a51 100644 --- a/engine/apps/alerts/escalation_snapshot/snapshot_classes/escalation_policy_snapshot.py +++ b/engine/apps/alerts/escalation_snapshot/snapshot_classes/escalation_policy_snapshot.py @@ -137,6 +137,7 @@ def execute(self, alert_group: "AlertGroup", reason: str) -> StepExecutionResult EscalationPolicy.STEP_NOTIFY_SCHEDULE_IMPORTANT: self._escalation_step_notify_on_call_schedule, EscalationPolicy.STEP_TRIGGER_CUSTOM_WEBHOOK: self._escalation_step_trigger_custom_webhook, EscalationPolicy.STEP_NOTIFY_USERS_QUEUE: self._escalation_step_notify_users_queue, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT: self._escalation_step_notify_users_queue, EscalationPolicy.STEP_NOTIFY_IF_TIME: self._escalation_step_notify_if_time, EscalationPolicy.STEP_NOTIFY_IF_NUM_ALERTS_IN_TIME_WINDOW: self._escalation_step_notify_if_num_alerts_in_time_window, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS: self._escalation_step_notify_multiple_users, @@ -199,6 +200,7 @@ def _escalation_step_notify_users_queue(self, alert_group: "AlertGroup", reason: ), { "reason": reason, + "important": self.step == EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, }, immutable=True, ) diff --git a/engine/apps/alerts/incident_log_builder/incident_log_builder.py b/engine/apps/alerts/incident_log_builder/incident_log_builder.py index d291d4fade..70410d96d5 100644 --- a/engine/apps/alerts/incident_log_builder/incident_log_builder.py +++ b/engine/apps/alerts/incident_log_builder/incident_log_builder.py @@ -100,9 +100,10 @@ def _get_log_records_for_after_resolve_report(self) -> "RelatedManager['AlertGro ] excluded_escalation_steps = [EscalationPolicy.STEP_WAIT, EscalationPolicy.STEP_FINAL_RESOLVE] not_excluded_steps_with_author = [ - EscalationPolicy.STEP_NOTIFY, - EscalationPolicy.STEP_NOTIFY_IMPORTANT, + EscalationPolicy._DEPRECATED_STEP_NOTIFY, + EscalationPolicy._DEPRECATED_STEP_NOTIFY_IMPORTANT, EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, ] # exclude logs that we don't want to see in after resolve report @@ -466,6 +467,7 @@ def _render_escalation_step_plan_from_escalation_policy_snapshot( EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, ]: users_to_notify: UsersToNotify = escalation_policy_snapshot.sorted_users_queue @@ -473,7 +475,10 @@ def _render_escalation_step_plan_from_escalation_policy_snapshot( if users_to_notify: plan_line = f'escalation step "{escalation_policy_snapshot.step_display}"' - if escalation_policy_snapshot.step == EscalationPolicy.STEP_NOTIFY_USERS_QUEUE: + if escalation_policy_snapshot.step in ( + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, + ): try: last_user_index = users_to_notify.index(escalation_policy_snapshot.last_notified_user) except ValueError: @@ -489,14 +494,21 @@ def _render_escalation_step_plan_from_escalation_policy_snapshot( escalation_plan.setdefault(timedelta, []).append({"plan_lines": [plan_line]}) - elif escalation_policy_snapshot.step == EscalationPolicy.STEP_NOTIFY_USERS_QUEUE: + elif escalation_policy_snapshot.step in ( + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, + ): last_notified_user = escalation_policy_snapshot.last_notified_user users_to_notify = [last_notified_user] if last_notified_user else [] for user_to_notify in users_to_notify: notification_plan = self._get_notification_plan_for_user( user_to_notify, - important=escalation_policy_snapshot.step == EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, + important=escalation_policy_snapshot.step + in [ + EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, + ], for_slack=for_slack, future_step=future_step, ) @@ -534,7 +546,6 @@ def _render_escalation_step_plan_from_escalation_policy_snapshot( for user_to_notify in final_notify_all_users_to_notify: notification_plan = self._get_notification_plan_for_user( user_to_notify, - important=escalation_policy_snapshot.step == EscalationPolicy.STEP_NOTIFY_IMPORTANT, for_slack=for_slack, future_step=future_step, ) diff --git a/engine/apps/alerts/migrations/0074_alter_escalationpolicy_step.py b/engine/apps/alerts/migrations/0074_alter_escalationpolicy_step.py new file mode 100644 index 0000000000..93a32ac4aa --- /dev/null +++ b/engine/apps/alerts/migrations/0074_alter_escalationpolicy_step.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.15 on 2025-01-20 10:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('alerts', '0073_update_direct_paging_integration_non_default_routes'), + ] + + operations = [ + migrations.AlterField( + model_name='escalationpolicy', + name='step', + field=models.IntegerField(choices=[(0, 'Wait'), (1, 'Notify User'), (2, 'Notify Whole Channel'), (3, 'Repeat Escalation (5 times max)'), (4, 'Resolve'), (5, 'Notify Group'), (6, 'Notify Schedule'), (7, 'Notify User (Important)'), (8, 'Notify Group (Important)'), (9, 'Notify Schedule (Important)'), (10, 'Trigger Outgoing Webhook'), (11, 'Notify User (next each time)'), (12, 'Continue escalation only if time is from'), (13, 'Notify multiple Users'), (14, 'Notify multiple Users (Important)'), (15, 'Continue escalation if >X alerts per Y minutes'), (16, 'Trigger Webhook'), (17, 'Notify all users in a Team'), (18, 'Notify all users in a Team (Important)'), (19, 'Declare Incident'), (20, 'Notify User (next each time) (Important)')], default=None, null=True), + ), + ] diff --git a/engine/apps/alerts/models/escalation_policy.py b/engine/apps/alerts/models/escalation_policy.py index e66a65c4f5..e4980fe159 100644 --- a/engine/apps/alerts/models/escalation_policy.py +++ b/engine/apps/alerts/models/escalation_policy.py @@ -29,13 +29,13 @@ class EscalationPolicy(OrderedModel): ( STEP_WAIT, - STEP_NOTIFY, + _DEPRECATED_STEP_NOTIFY, # only here to keep range intact STEP_FINAL_NOTIFYALL, STEP_REPEAT_ESCALATION_N_TIMES, STEP_FINAL_RESOLVE, STEP_NOTIFY_GROUP, STEP_NOTIFY_SCHEDULE, - STEP_NOTIFY_IMPORTANT, + _DEPRECATED_STEP_NOTIFY_IMPORTANT, # only here to keep range intact STEP_NOTIFY_GROUP_IMPORTANT, STEP_NOTIFY_SCHEDULE_IMPORTANT, _DEPRECATED_STEP_TRIGGER_CUSTOM_BUTTON, # only here to keep range intact @@ -48,18 +48,19 @@ class EscalationPolicy(OrderedModel): STEP_NOTIFY_TEAM_MEMBERS, STEP_NOTIFY_TEAM_MEMBERS_IMPORTANT, STEP_DECLARE_INCIDENT, - ) = range(20) + STEP_NOTIFY_USERS_QUEUE_IMPORTANT, + ) = range(21) # Must be the same order as previous STEP_CHOICES = ( (STEP_WAIT, "Wait"), - (STEP_NOTIFY, "Notify User"), + (_DEPRECATED_STEP_NOTIFY, "Notify User"), (STEP_FINAL_NOTIFYALL, "Notify Whole Channel"), (STEP_REPEAT_ESCALATION_N_TIMES, "Repeat Escalation (5 times max)"), (STEP_FINAL_RESOLVE, "Resolve"), (STEP_NOTIFY_GROUP, "Notify Group"), (STEP_NOTIFY_SCHEDULE, "Notify Schedule"), - (STEP_NOTIFY_IMPORTANT, "Notify User (Important)"), + (_DEPRECATED_STEP_NOTIFY_IMPORTANT, "Notify User (Important)"), (STEP_NOTIFY_GROUP_IMPORTANT, "Notify Group (Important)"), (STEP_NOTIFY_SCHEDULE_IMPORTANT, "Notify Schedule (Important)"), (_DEPRECATED_STEP_TRIGGER_CUSTOM_BUTTON, "Trigger Outgoing Webhook"), @@ -72,6 +73,7 @@ class EscalationPolicy(OrderedModel): (STEP_NOTIFY_TEAM_MEMBERS, "Notify all users in a Team"), (STEP_NOTIFY_TEAM_MEMBERS_IMPORTANT, "Notify all users in a Team (Important)"), (STEP_DECLARE_INCIDENT, "Declare Incident"), + (STEP_NOTIFY_USERS_QUEUE_IMPORTANT, "Notify User (next each time) (Important)"), ) # Ordered step choices available for internal api. @@ -114,6 +116,7 @@ class EscalationPolicy(OrderedModel): STEP_TRIGGER_CUSTOM_WEBHOOK, STEP_REPEAT_ESCALATION_N_TIMES, STEP_DECLARE_INCIDENT, + STEP_NOTIFY_USERS_QUEUE_IMPORTANT, ] # Maps internal api's steps choices to their verbal. First string in tuple is display name for existent step. @@ -142,7 +145,10 @@ class EscalationPolicy(OrderedModel): ), # Other STEP_TRIGGER_CUSTOM_WEBHOOK: ("Trigger webhook {{custom_webhook}}", "Trigger webhook"), - STEP_NOTIFY_USERS_QUEUE: ("Round robin notification for {{users}}", "Notify users one by one (round-robin)"), + STEP_NOTIFY_USERS_QUEUE: ( + "Round robin {{importance}} notification for {{users}}", + "Notify users one by one (round-robin)", + ), STEP_NOTIFY_IF_TIME: ( "Continue escalation if current UTC time is in {{timerange}}", "Continue escalation if current UTC time is in range", @@ -166,7 +172,6 @@ class EscalationPolicy(OrderedModel): STEP_FINAL_NOTIFYALL, STEP_FINAL_RESOLVE, STEP_TRIGGER_CUSTOM_WEBHOOK, - STEP_NOTIFY_USERS_QUEUE, STEP_NOTIFY_IF_TIME, STEP_REPEAT_ESCALATION_N_TIMES, STEP_DECLARE_INCIDENT, @@ -177,12 +182,14 @@ class EscalationPolicy(OrderedModel): STEP_NOTIFY_SCHEDULE: STEP_NOTIFY_SCHEDULE_IMPORTANT, STEP_NOTIFY_MULTIPLE_USERS: STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, STEP_NOTIFY_TEAM_MEMBERS: STEP_NOTIFY_TEAM_MEMBERS_IMPORTANT, + STEP_NOTIFY_USERS_QUEUE: STEP_NOTIFY_USERS_QUEUE_IMPORTANT, } IMPORTANT_TO_DEFAULT_STEP_MAPPING = { STEP_NOTIFY_GROUP_IMPORTANT: STEP_NOTIFY_GROUP, STEP_NOTIFY_SCHEDULE_IMPORTANT: STEP_NOTIFY_SCHEDULE, STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT: STEP_NOTIFY_MULTIPLE_USERS, STEP_NOTIFY_TEAM_MEMBERS_IMPORTANT: STEP_NOTIFY_TEAM_MEMBERS, + STEP_NOTIFY_USERS_QUEUE_IMPORTANT: STEP_NOTIFY_USERS_QUEUE, } # Default steps are just usual version of important steps. E.g. notify group - notify group important @@ -191,6 +198,7 @@ class EscalationPolicy(OrderedModel): STEP_NOTIFY_SCHEDULE, STEP_NOTIFY_MULTIPLE_USERS, STEP_NOTIFY_TEAM_MEMBERS, + STEP_NOTIFY_USERS_QUEUE, } IMPORTANT_STEPS_SET = { @@ -198,6 +206,7 @@ class EscalationPolicy(OrderedModel): STEP_NOTIFY_SCHEDULE_IMPORTANT, STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, STEP_NOTIFY_TEAM_MEMBERS_IMPORTANT, + STEP_NOTIFY_USERS_QUEUE_IMPORTANT, } SLACK_INTEGRATION_REQUIRED_STEPS = [ @@ -224,12 +233,10 @@ class EscalationPolicy(OrderedModel): PUBLIC_STEP_CHOICES_MAP = { STEP_WAIT: "wait", - STEP_NOTIFY: "notify_one_person", STEP_FINAL_NOTIFYALL: "notify_whole_channel", STEP_FINAL_RESOLVE: "resolve", STEP_NOTIFY_GROUP: "notify_user_group", STEP_NOTIFY_GROUP_IMPORTANT: "notify_user_group", - STEP_NOTIFY_IMPORTANT: "notify_one_person", STEP_NOTIFY_SCHEDULE: "notify_on_call_from_schedule", STEP_NOTIFY_SCHEDULE_IMPORTANT: "notify_on_call_from_schedule", STEP_TRIGGER_CUSTOM_WEBHOOK: "trigger_webhook", diff --git a/engine/apps/alerts/tests/test_escalation_policy_snapshot.py b/engine/apps/alerts/tests/test_escalation_policy_snapshot.py index 8882a37012..a09d1ca2bd 100644 --- a/engine/apps/alerts/tests/test_escalation_policy_snapshot.py +++ b/engine/apps/alerts/tests/test_escalation_policy_snapshot.py @@ -93,9 +93,13 @@ def test_escalation_step_notify_all( @patch("apps.alerts.escalation_snapshot.snapshot_classes.EscalationPolicySnapshot._execute_tasks", return_value=None) +@pytest.mark.parametrize( + "step", [EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT] +) @pytest.mark.django_db def test_escalation_step_notify_users_queue( mocked_execute_tasks, + step, make_user_for_organization, escalation_step_test_setup, make_escalation_policy, @@ -105,7 +109,7 @@ def test_escalation_step_notify_users_queue( notify_queue_step = make_escalation_policy( escalation_chain=channel_filter.escalation_chain, - escalation_policy_step=EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + escalation_policy_step=step, ) notify_queue_step.notify_to_users_queue.set([user, user_2]) escalation_policy_snapshot = get_escalation_policy_snapshot_from_model(notify_queue_step) diff --git a/engine/apps/api/tests/test_escalation_policy.py b/engine/apps/api/tests/test_escalation_policy.py index 3ad2583cd5..a4027aea28 100644 --- a/engine/apps/api/tests/test_escalation_policy.py +++ b/engine/apps/api/tests/test_escalation_policy.py @@ -511,6 +511,7 @@ def test_escalation_policy_move_to_position_permissions( (EscalationPolicy.STEP_NOTIFY_GROUP_IMPORTANT, EscalationPolicy.STEP_NOTIFY_GROUP), (EscalationPolicy.STEP_NOTIFY_SCHEDULE_IMPORTANT, EscalationPolicy.STEP_NOTIFY_SCHEDULE), (EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS), + (EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, EscalationPolicy.STEP_NOTIFY_USERS_QUEUE), ], ) def test_escalation_policy_maps_default_to_important( @@ -545,6 +546,7 @@ def test_escalation_policy_maps_default_to_important( EscalationPolicy.STEP_NOTIFY_GROUP, EscalationPolicy.STEP_NOTIFY_SCHEDULE, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, ], ) def test_escalation_policy_default_steps_stay_default( @@ -578,6 +580,7 @@ def test_escalation_policy_default_steps_stay_default( (EscalationPolicy.STEP_NOTIFY_GROUP, EscalationPolicy.STEP_NOTIFY_GROUP_IMPORTANT), (EscalationPolicy.STEP_NOTIFY_SCHEDULE, EscalationPolicy.STEP_NOTIFY_SCHEDULE_IMPORTANT), (EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT), + (EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT), ], ) def test_create_escalation_policy_important( @@ -615,6 +618,7 @@ def test_create_escalation_policy_important( EscalationPolicy.STEP_NOTIFY_GROUP, EscalationPolicy.STEP_NOTIFY_SCHEDULE, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, ], ) def test_create_escalation_policy_default( diff --git a/engine/apps/public_api/serializers/escalation_policies.py b/engine/apps/public_api/serializers/escalation_policies.py index 92796a5db6..1977b2101c 100644 --- a/engine/apps/public_api/serializers/escalation_policies.py +++ b/engine/apps/public_api/serializers/escalation_policies.py @@ -191,7 +191,10 @@ def _get_field_to_represent(self, step, result): EscalationPolicy.STEP_NOTIFY_TEAM_MEMBERS_IMPORTANT, ]: fields_to_remove.remove("team_to_notify") - elif step == EscalationPolicy.STEP_NOTIFY_USERS_QUEUE: + elif step in [ + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, + ]: fields_to_remove.remove("persons_to_notify_next_each_time") elif step in [EscalationPolicy.STEP_NOTIFY_GROUP, EscalationPolicy.STEP_NOTIFY_GROUP_IMPORTANT]: fields_to_remove.remove("group_to_notify") @@ -243,6 +246,7 @@ def _correct_validated_data(self, validated_data): validated_data_fields_to_remove.remove("wait_delay") elif step in [ EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, ]: @@ -298,6 +302,7 @@ def update(self, instance, validated_data): instance.wait_delay = None if step not in [ EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, ]: diff --git a/engine/apps/webhooks/utils.py b/engine/apps/webhooks/utils.py index f3b90e5593..b3a100d3e9 100644 --- a/engine/apps/webhooks/utils.py +++ b/engine/apps/webhooks/utils.py @@ -132,13 +132,17 @@ def _extract_users_from_escalation_snapshot(escalation_snapshot): if escalation_snapshot: for policy_snapshot in escalation_snapshot.escalation_policies_snapshots: if policy_snapshot.step in [ - EscalationPolicy.STEP_NOTIFY, - EscalationPolicy.STEP_NOTIFY_IMPORTANT, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS, EscalationPolicy.STEP_NOTIFY_MULTIPLE_USERS_IMPORTANT, ]: for user in policy_snapshot.notify_to_users_queue: users.append(_serialize_event_user(user)) + elif policy_snapshot.step in [ + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE, + EscalationPolicy.STEP_NOTIFY_USERS_QUEUE_IMPORTANT, + ]: + if policy_snapshot.notify_to_users_queue: + users.append(_serialize_event_user(policy_snapshot.next_user_in_sorted_queue)) elif policy_snapshot.step in [ EscalationPolicy.STEP_NOTIFY_SCHEDULE, EscalationPolicy.STEP_NOTIFY_SCHEDULE_IMPORTANT,