Skip to content
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

Ensuring that the assignee override is respected #3468

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/dispatch/signal/flows.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from datetime import timedelta
import logging
from cachetools import TTLCache
from datetime import timedelta

from email_validator import validate_email, EmailNotValidError
from cachetools import TTLCache
from email_validator import EmailNotValidError, validate_email
from sqlalchemy.orm import Session

from dispatch.auth.models import DispatchUser, UserRegister
from dispatch.auth import service as user_service
from dispatch.auth.models import DispatchUser, UserRegister
from dispatch.case import flows as case_flows
from dispatch.case import service as case_service
from dispatch.case.models import CaseCreate
from dispatch.entity import service as entity_service
from dispatch.exceptions import DispatchException
from dispatch.plugin import service as plugin_service
from dispatch.project.models import Project
from dispatch.signal import service as signal_service
from dispatch.service import flows as service_flows
from dispatch.signal import flows as signal_flows
from dispatch.signal import service as signal_service
from dispatch.signal.enums import SignalEngagementStatus
from dispatch.signal.models import SignalInstance, SignalInstanceCreate, SignalFilterAction
from dispatch.signal.models import SignalFilterAction, SignalInstance, SignalInstanceCreate
from dispatch.workflow import flows as workflow_flows

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -59,6 +60,7 @@ def signal_instance_create_flow(
if not signal_instance.signal.create_case:
return signal_instance

# process signal <-> case overrides
if signal_instance.case_priority:
case_priority = signal_instance.case_priority
else:
Expand All @@ -69,27 +71,30 @@ def signal_instance_create_flow(
else:
case_type = signal_instance.signal.case_type

service_id = None
if signal_instance.signal.oncall_service:
assignee_email = service_flows.resolve_oncall(
service=signal_instance.signal.oncall_service, db_session=db_session
)

conversation_target = None
if signal_instance.signal.conversation_target:
conversation_target = signal_instance.signal.conversation_target

# create a case if not duplicate or snoozed and case creation is enabled
case_in = CaseCreate(
title=signal_instance.signal.name,
description=signal_instance.signal.description,
case_priority=case_priority,
project=signal_instance.project,
case_type=case_type,
assignee={"individual": {"email": assignee_email}},
)
case = case_service.create(db_session=db_session, case_in=case_in, current_user=current_user)
signal_instance.case = case

db_session.commit()

service_id = None
if signal_instance.signal.oncall_service:
service_id = signal_instance.signal.oncall_service.external_id

conversation_target = None
if signal_instance.signal.conversation_target:
conversation_target = signal_instance.signal.conversation_target

case_flows.case_new_create_flow(
db_session=db_session,
organization_slug=None,
Expand Down