|
11 | 11 | from dispatch.database.core import SessionLocal
|
12 | 12 | from dispatch.decorators import background_task
|
13 | 13 | from dispatch.document import flows as document_flows
|
14 |
| -from dispatch.enums import DocumentResourceTypes, Visibility, EventType |
| 14 | +from dispatch.enums import DocumentResourceTypes, EventType, Visibility |
15 | 15 | from dispatch.event import service as event_service
|
16 | 16 | from dispatch.group import flows as group_flows
|
17 | 17 | from dispatch.group.enums import GroupAction, GroupType
|
18 | 18 | from dispatch.incident import flows as incident_flows
|
19 | 19 | from dispatch.incident import service as incident_service
|
20 | 20 | from dispatch.incident.enums import IncidentStatus
|
21 | 21 | from dispatch.incident.messaging import send_participant_announcement_message
|
22 |
| -from dispatch.incident.models import IncidentCreate, Incident |
23 |
| -from dispatch.incident.type.models import IncidentType |
| 22 | +from dispatch.incident.models import Incident, IncidentCreate |
24 | 23 | from dispatch.incident.priority.models import IncidentPriority
|
| 24 | +from dispatch.incident.type.models import IncidentType |
25 | 25 | from dispatch.individual.models import IndividualContactRead
|
26 | 26 | from dispatch.models import OrganizationSlug, PrimaryKey
|
27 | 27 | from dispatch.participant import flows as participant_flows
|
28 | 28 | from dispatch.participant import service as participant_service
|
29 | 29 | from dispatch.participant.models import ParticipantUpdate
|
30 | 30 | from dispatch.participant_role import flows as role_flow
|
31 |
| -from dispatch.participant_role.models import ParticipantRoleType, ParticipantRole |
| 31 | +from dispatch.participant_role.models import ParticipantRole, ParticipantRoleType |
32 | 32 | from dispatch.plugin import service as plugin_service
|
33 | 33 | from dispatch.storage import flows as storage_flows
|
34 | 34 | from dispatch.storage.enums import StorageAction
|
35 | 35 | from dispatch.ticket import flows as ticket_flows
|
36 | 36 |
|
37 | 37 | from .messaging import (
|
38 | 38 | send_case_created_notifications,
|
39 |
| - send_case_update_notifications, |
40 | 39 | send_case_rating_feedback_message,
|
| 40 | + send_case_update_notifications, |
41 | 41 | )
|
42 |
| - |
43 | 42 | from .models import Case, CaseStatus
|
44 | 43 | from .service import get
|
45 | 44 |
|
@@ -337,17 +336,17 @@ def case_update_flow(
|
337 | 336 | # we get the case
|
338 | 337 | case = get(db_session=db_session, case_id=case_id)
|
339 | 338 |
|
340 |
| - if reporter_email: |
341 |
| - # we run the case assign role flow for the reporter |
| 339 | + if reporter_email and case and reporter_email != case.reporter.email: |
| 340 | + # we run the case assign role flow for the reporter if it changed |
342 | 341 | case_assign_role_flow(
|
343 | 342 | case_id=case.id,
|
344 | 343 | participant_email=reporter_email,
|
345 | 344 | participant_role=ParticipantRoleType.reporter,
|
346 | 345 | db_session=db_session,
|
347 | 346 | )
|
348 | 347 |
|
349 |
| - if assignee_email: |
350 |
| - # we run the case assign role flow for the assignee |
| 348 | + if assignee_email and case and assignee_email != case.assignee.email: |
| 349 | + # we run the case assign role flow for the assignee if it changed |
351 | 350 | case_assign_role_flow(
|
352 | 351 | case_id=case.id,
|
353 | 352 | participant_email=assignee_email,
|
@@ -375,15 +374,15 @@ def case_update_flow(
|
375 | 374 |
|
376 | 375 | if case.tactical_group:
|
377 | 376 | # we update the tactical group
|
378 |
| - if reporter_email: |
| 377 | + if reporter_email and reporter_email != case.reporter.email: |
379 | 378 | group_flows.update_group(
|
380 | 379 | subject=case,
|
381 | 380 | group=case.tactical_group,
|
382 | 381 | group_action=GroupAction.add_member,
|
383 | 382 | group_member=reporter_email,
|
384 | 383 | db_session=db_session,
|
385 | 384 | )
|
386 |
| - if assignee_email: |
| 385 | + if assignee_email and assignee_email != case.assignee.email: |
387 | 386 | group_flows.update_group(
|
388 | 387 | subject=case,
|
389 | 388 | group=case.tactical_group,
|
|
0 commit comments