Fix slack schedule notification settings dialog (#2902)
Fixes https://github.com/grafana/oncall/issues/2647
This commit is contained in:
parent
65bceaa297
commit
0e75be96df
3 changed files with 44 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
updated to reflect the latest state by @joeyorlando ([#2886](https://github.com/grafana/oncall/pull/2886))
|
||||
- Fix issue where Grafana integration would fail to parse alerting config for routes without receivers @mderynck
|
||||
([#2894](https://github.com/grafana/oncall/pull/2894))
|
||||
- Fix slack schedule notification settings dialog ([#2902](https://github.com/grafana/oncall/pull/2902))
|
||||
|
||||
## v1.3.27 (2023-08-25)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from rest_framework.test import APIClient
|
|||
|
||||
from apps.slack.scenarios.manage_responders import ManageRespondersUserChange
|
||||
from apps.slack.scenarios.paging import OnPagingTeamChange
|
||||
from apps.slack.scenarios.schedules import EditScheduleShiftNotifyStep
|
||||
from apps.slack.scenarios.shift_swap_requests import AcceptShiftSwapRequestStep
|
||||
from apps.slack.types import PayloadType
|
||||
|
||||
|
|
@ -200,6 +201,37 @@ def test_organization_not_found_scenario_doesnt_break_manage_responders(
|
|||
mock_process_scenario.assert_called_once()
|
||||
|
||||
|
||||
@patch("apps.slack.views.SlackEventApiEndpointView.verify_signature", return_value=True)
|
||||
@patch.object(EditScheduleShiftNotifyStep, "process_scenario")
|
||||
@pytest.mark.django_db
|
||||
def test_organization_not_found_scenario_doesnt_break_edit_schedule_notifications(
|
||||
mock_edit_schedule_notifications,
|
||||
_,
|
||||
make_organization,
|
||||
make_slack_user_identity,
|
||||
make_user,
|
||||
slack_team_identity,
|
||||
):
|
||||
"""
|
||||
Check EditScheduleShiftNotifyStep.process_scenario gets called when a user clicks settings in shift notification.
|
||||
"""
|
||||
organization = make_organization(slack_team_identity=slack_team_identity)
|
||||
slack_user_identity = make_slack_user_identity(slack_team_identity=slack_team_identity, slack_id=SLACK_USER_ID)
|
||||
make_user(organization=organization, slack_user_identity=slack_user_identity)
|
||||
|
||||
response = _make_request(
|
||||
{
|
||||
"team_id": SLACK_TEAM_ID,
|
||||
"user_id": SLACK_USER_ID,
|
||||
"type": "block_actions",
|
||||
"actions": [{"action_id": EditScheduleShiftNotifyStep.routing_uid(), "type": "button"}],
|
||||
}
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
mock_edit_schedule_notifications.assert_called_once()
|
||||
|
||||
|
||||
@patch("apps.slack.views.SlackEventApiEndpointView.verify_signature", return_value=True)
|
||||
@patch.object(AcceptShiftSwapRequestStep, "process_scenario")
|
||||
@pytest.mark.django_db
|
||||
|
|
|
|||
|
|
@ -143,6 +143,11 @@ class SlackEventApiEndpointView(APIView):
|
|||
payload_user = payload.get("user")
|
||||
payload_user_id = payload.get("user_id")
|
||||
|
||||
edit_schedule_actions = {s["block_action_id"] for s in SCHEDULES_ROUTING}
|
||||
payload_action_edit_schedule = (
|
||||
payload_actions[0].get("action_id") in edit_schedule_actions if payload_actions else False
|
||||
)
|
||||
|
||||
payload_event = payload.get("event", {})
|
||||
payload_event_type = payload_event.get("type")
|
||||
payload_event_subtype = payload_event.get("subtype")
|
||||
|
|
@ -272,8 +277,12 @@ class SlackEventApiEndpointView(APIView):
|
|||
# Open pop-up to inform user why OnCall bot doesn't work if any action was triggered
|
||||
self._open_warning_window_if_needed(payload, slack_team_identity, warning_text)
|
||||
return Response(status=200)
|
||||
# direct paging / manual incident dialogs don't require organization to be set
|
||||
elif organization is None and payload_type_is_block_actions and not payload.get("view"):
|
||||
# direct paging / manual incident / schedule update dialogs don't require organization to be set
|
||||
elif (
|
||||
organization is None
|
||||
and payload_type_is_block_actions
|
||||
and not (payload.get("view") or payload_action_edit_schedule)
|
||||
):
|
||||
# see this GitHub issue for more context on how this situation can arise
|
||||
# https://github.com/grafana/oncall-private/issues/1836
|
||||
warning_text = (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue