-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Revert slack org does not exist changes breaking escalate command (#2057)" #2096
Conversation
some cleanup
…afana/oncall into jorlando/revert-orgnotfound-slack-fix
@@ -285,55 +301,73 @@ def post(self, request): | |||
# 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) | |||
elif organization is None and payload_type_is_block_actions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and payload_type_is_block_actions
is the main change of this PR.
From what I can see from the logs,Organization matching query does not exist.
exceptions originating from this endpoint only seem to be happening when payload_type == 'block_actions'
payload_type = payload.get("type") | ||
payload_type_is_block_actions = payload_type == PAYLOAD_TYPE_BLOCK_ACTIONS | ||
payload_command = payload.get("command") | ||
payload_callback_id = payload.get("callback_id") | ||
payload_actions = payload.get("actions", []) | ||
payload_user = payload.get("user") | ||
payload_user_id = payload.get("user_id") | ||
|
||
payload_event = payload.get("event", {}) | ||
payload_event_type = payload_event.get("type") | ||
payload_event_subtype = payload_event.get("subtype") | ||
payload_event_user = payload_event.get("user") | ||
payload_event_bot_id = payload_event.get("bot_id") | ||
payload_event_channel_type = payload_event.get("channel_type") | ||
|
||
payload_event_message = payload_event.get("message", {}) | ||
payload_event_message_user = payload_event_message.get("user") | ||
|
||
payload_event_previous_message = payload_event.get("previous_message", {}) | ||
payload_event_previous_message_user = payload_event_previous_message.get("user") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decided to clean this up a bit, much less repetitive imo
@patch("apps.slack.views.SlackEventApiEndpointView.verify_signature", return_value=True) | ||
@patch("apps.slack.views.SlackEventApiEndpointView._open_warning_window_if_needed") | ||
@pytest.mark.django_db | ||
def test_organization_not_found_scenario_doesnt_break_slash_commands( | ||
mock_open_warning_window_if_needed, | ||
_mock_verify_signature, | ||
make_organization, | ||
make_slack_user_identity, | ||
slack_team_identity, | ||
): | ||
|
||
make_organization(slack_team_identity=slack_team_identity) | ||
make_slack_user_identity(slack_team_identity=slack_team_identity, slack_id=SLACK_USER_ID) | ||
|
||
response = _make_request( | ||
{ | ||
"token": "axvnc,mvc,mv,mcvmnxcmnxc", | ||
"team_id": SLACK_TEAM_ID, | ||
"team_domain": "testingtest-nim4013", | ||
"channel_id": "C043HQ70QMB", | ||
"channel_name": "testy-testing", | ||
"user_id": "U043HQ3VABF", | ||
"user_name": "bob.smith", | ||
"command": settings.SLACK_DIRECT_PAGING_SLASH_COMMAND, | ||
"text": "potato", | ||
"api_app_id": "A0909234092340293402934234234234234234", | ||
"is_enterprise_install": "false", | ||
"response_url": "https://hooks.slack.com/commands/cvcv/cvcv/cvcv", | ||
"trigger_id": "asdfasdf.4122782784722.cvcv", | ||
} | ||
) | ||
|
||
assert response.status_code == status.HTTP_200_OK | ||
mock_open_warning_window_if_needed.assert_not_called() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously this PR broke the /escalate
command, added a test to ensure this is no longer the case. The request payload structure being sent here is identical to that when the /escalate
command is used.
payload_view = payload.get("view", {}) | ||
payload_view_state = payload_view.get("state", {}) | ||
payload_view_state_values = payload_view_state.get("values", {}) | ||
|
||
payload_event = payload.get("event", {}) | ||
payload_event_channel = payload_event.get("channel") | ||
payload_event_message = payload_event.get("message", {}) | ||
payload_event_thread_ts = payload_event.get("thread_ts") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. wanted to clean this up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does
Closes https://github.com/grafana/oncall-private/issues/1836
/escalate
command in the futurepayload
dict in the endpoint handlerChecklist
pr:no public docs
PR label added if not required)CHANGELOG.md
updated (orpr:no changelog
PR label added if not required)