This PR supports new flow of selecting org to run command in a slack workspace if several stacks are using it. In this case user selects default stack to run commands or pass a --stack flag. Both handled by chatops-proxy which injects selected stack as a header. On a side note - I found one ScenarioStep with incompatible set of arguments with parent class. I didn't fixed it, just left TODO https://github.com/grafana/oncall/pull/4578/files#diff-e323b5f38ed665f73d5da3fa0575958ed54ab587f6521b4cd87e1491b5430f8bR364 Related to https://github.com/grafana/oncall-gateway/issues/256 --------- Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
import logging
|
|
import typing
|
|
|
|
from apps.slack.scenarios import scenario_step
|
|
from apps.slack.types import EventPayload, EventType, PayloadType, ScenarioRoute
|
|
|
|
if typing.TYPE_CHECKING:
|
|
from apps.slack.models import SlackTeamIdentity, SlackUserIdentity
|
|
from apps.user_management.models import Organization
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ImOpenStep(scenario_step.ScenarioStep):
|
|
"""
|
|
Empty step to handle event and avoid 500's. In case we need it in the future.
|
|
"""
|
|
|
|
def process_scenario(
|
|
self,
|
|
slack_user_identity: "SlackUserIdentity",
|
|
slack_team_identity: "SlackTeamIdentity",
|
|
payload: "EventPayload",
|
|
predefined_org: typing.Optional["Organization"] = None,
|
|
) -> None:
|
|
logger.info("InOpenStep, doing nothing.")
|
|
|
|
|
|
class AppHomeOpenedStep(scenario_step.ScenarioStep):
|
|
def process_scenario(
|
|
self,
|
|
slack_user_identity: "SlackUserIdentity",
|
|
slack_team_identity: "SlackTeamIdentity",
|
|
payload: "EventPayload",
|
|
predefined_org: typing.Optional["Organization"] = None,
|
|
) -> None:
|
|
pass
|
|
|
|
|
|
STEPS_ROUTING: ScenarioRoute.RoutingSteps = [
|
|
{
|
|
"payload_type": PayloadType.EVENT_CALLBACK,
|
|
"event_type": EventType.IM_OPEN,
|
|
"step": ImOpenStep,
|
|
},
|
|
{
|
|
"payload_type": PayloadType.EVENT_CALLBACK,
|
|
"event_type": EventType.APP_HOME_OPENED,
|
|
"step": AppHomeOpenedStep,
|
|
},
|
|
]
|