Skip to content

Commit

Permalink
Logs a warning if ticket plugin is not enabled on ticket creation (#2291
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mvilanova authored Jun 24, 2022
1 parent fb83639 commit e3b2b46
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions src/dispatch/incident/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,37 +123,40 @@ def create_incident_ticket(incident: Incident, db_session: SessionLocal):
plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=incident.project.id, plugin_type="ticket"
)
if plugin:
title = incident.title
if incident.visibility == Visibility.restricted:
title = incident.incident_type.name
if not plugin:
log.warning("Incident ticket not created. No ticket plugin enabled.")
return

incident_type_plugin_metadata = incident_type_service.get_by_name_or_raise(
db_session=db_session,
project_id=incident.project.id,
incident_type_in=incident.incident_type,
).get_meta(plugin.plugin.slug)

ticket = plugin.instance.create(
incident.id,
title,
incident.incident_type.name,
incident.incident_priority.name,
incident.commander.individual.email,
incident.reporter.individual.email,
incident_type_plugin_metadata,
db_session=db_session,
)
ticket.update({"resource_type": plugin.plugin.slug})
title = incident.title
if incident.visibility == Visibility.restricted:
title = incident.incident_type.name

event_service.log(
db_session=db_session,
source=plugin.plugin.title,
description="Ticket created",
incident_id=incident.id,
)
incident_type_plugin_metadata = incident_type_service.get_by_name_or_raise(
db_session=db_session,
project_id=incident.project.id,
incident_type_in=incident.incident_type,
).get_meta(plugin.plugin.slug)

ticket = plugin.instance.create(
incident.id,
title,
incident.incident_type.name,
incident.incident_priority.name,
incident.commander.individual.email,
incident.reporter.individual.email,
incident_type_plugin_metadata,
db_session=db_session,
)
ticket.update({"resource_type": plugin.plugin.slug})

event_service.log(
db_session=db_session,
source=plugin.plugin.title,
description="Ticket created",
incident_id=incident.id,
)

return ticket
return ticket


def update_external_incident_ticket(
Expand Down

0 comments on commit e3b2b46

Please sign in to comment.