Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Commit 0530c55

Browse files
committed
techdebt(plugin): deprecates the document resolver plugin and its code
1 parent c87f545 commit 0530c55

File tree

6 files changed

+26
-145
lines changed

6 files changed

+26
-145
lines changed

src/dispatch/incident/flows.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,57 @@
11
import logging
2-
32
from datetime import datetime
43
from typing import Optional
54

65
from sqlalchemy.orm import Session
76

8-
from dispatch.case.models import Case
97
from dispatch.case import service as case_service
8+
from dispatch.case.models import Case
109
from dispatch.conference import flows as conference_flows
1110
from dispatch.conversation import flows as conversation_flows
1211
from dispatch.database.core import resolve_attr
1312
from dispatch.decorators import background_task
1413
from dispatch.document import flows as document_flows
1514
from dispatch.document.models import Document
16-
from dispatch.enums import DocumentResourceTypes
17-
from dispatch.enums import Visibility, EventType
15+
from dispatch.enums import DocumentResourceTypes, EventType, Visibility
1816
from dispatch.event import service as event_service
1917
from dispatch.group import flows as group_flows
20-
from dispatch.group.enums import GroupType, GroupAction
18+
from dispatch.group.enums import GroupAction, GroupType
2119
from dispatch.incident import service as incident_service
2220
from dispatch.incident.models import IncidentRead
2321
from dispatch.incident_cost import service as incident_cost_service
2422
from dispatch.individual import service as individual_service
23+
from dispatch.individual.models import IndividualContact
2524
from dispatch.participant import flows as participant_flows
2625
from dispatch.participant import service as participant_service
2726
from dispatch.participant.models import Participant
28-
from dispatch.individual.models import IndividualContact
29-
from dispatch.team.models import TeamContact
3027
from dispatch.participant_role import flows as participant_role_flows
3128
from dispatch.participant_role.models import ParticipantRoleType
3229
from dispatch.plugin import service as plugin_service
3330
from dispatch.report.enums import ReportTypes
3431
from dispatch.report.messaging import send_incident_report_reminder
3532
from dispatch.service import service as service_service
3633
from dispatch.storage import flows as storage_flows
34+
from dispatch.tag.flows import check_for_tag_change
3735
from dispatch.task.enums import TaskStatus
36+
from dispatch.team.models import TeamContact
3837
from dispatch.ticket import flows as ticket_flows
39-
from dispatch.tag.flows import check_for_tag_change
4038

4139
from .messaging import (
42-
# get_suggested_document_items,
40+
bulk_participant_announcement_message,
4341
send_incident_closed_information_review_reminder,
4442
send_incident_commander_readded_notification,
4543
send_incident_created_notifications,
4644
send_incident_management_help_tips_message,
4745
send_incident_new_role_assigned_notification,
4846
send_incident_open_tasks_ephemeral_message,
49-
send_participant_announcement_message,
50-
bulk_participant_announcement_message,
5147
send_incident_rating_feedback_message,
5248
send_incident_review_document_notification,
53-
# send_incident_suggested_reading_messages,
5449
send_incident_update_notifications,
5550
send_incident_welcome_participant_messages,
51+
send_participant_announcement_message,
5652
)
5753
from .models import Incident, IncidentStatus
5854

59-
6055
log = logging.getLogger(__name__)
6156

6257

@@ -315,13 +310,6 @@ def incident_create_resources(
315310
# we send the welcome messages to the participant
316311
send_incident_welcome_participant_messages(user_email, incident, db_session)
317312

318-
# NOTE: Temporarily disabled until an issue with the Dispatch resolver plugin is resolved
319-
# we send a suggested reading message to the participant
320-
# suggested_document_items = get_suggested_document_items(incident, db_session)
321-
# send_incident_suggested_reading_messages(
322-
# incident, suggested_document_items, user_email, db_session
323-
# )
324-
325313
bulk_participant_announcement_message(
326314
participant_emails=user_emails,
327315
subject=incident,
@@ -1051,13 +1039,6 @@ def incident_add_or_reactivate_participant_flow(
10511039
# we send the welcome messages to the participant
10521040
send_incident_welcome_participant_messages(user_email, incident, db_session)
10531041

1054-
# NOTE: Temporarily disabled until an issue with the Dispatch resolver plugin is resolved
1055-
# we send a suggested reading message to the participant
1056-
# suggested_document_items = get_suggested_document_items(incident, db_session)
1057-
# send_incident_suggested_reading_messages(
1058-
# incident, suggested_document_items, user_email, db_session
1059-
# )
1060-
10611042
return participant
10621043

10631044

src/dispatch/incident/messaging.py

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,55 @@
66
"""
77

88
import logging
9-
109
from typing import Optional
1110

1211
from slack_sdk.errors import SlackApiError
1312
from sqlalchemy.orm import Session
1413

15-
from dispatch.decorators import timer
1614
from dispatch.config import DISPATCH_UI_URL
1715
from dispatch.conversation.enums import ConversationCommands
1816
from dispatch.database.core import SessionLocal, resolve_attr
17+
from dispatch.decorators import timer
1918
from dispatch.document import service as document_service
20-
from dispatch.email_templates.models import EmailTemplates
2119
from dispatch.email_templates import service as email_template_service
2220
from dispatch.email_templates.enums import EmailTemplateTypes
21+
from dispatch.email_templates.models import EmailTemplates
2322
from dispatch.enums import SubjectNames
2423
from dispatch.event import service as event_service
24+
from dispatch.forms.models import Forms
2525
from dispatch.incident.enums import IncidentStatus
2626
from dispatch.incident.models import Incident, IncidentRead
27-
from dispatch.notification import service as notification_service
28-
from dispatch.forms.models import Forms
2927
from dispatch.messaging.strings import (
28+
INCIDENT_CLOSE_REMINDER,
3029
INCIDENT_CLOSED_INFORMATION_REVIEW_REMINDER_NOTIFICATION,
3130
INCIDENT_CLOSED_RATING_FEEDBACK_NOTIFICATION,
32-
INCIDENT_CLOSE_REMINDER,
3331
INCIDENT_COMMANDER,
3432
INCIDENT_COMMANDER_READDED_NOTIFICATION,
33+
INCIDENT_COMPLETED_FORM_MESSAGE,
3534
INCIDENT_MANAGEMENT_HELP_TIPS_MESSAGE,
3635
INCIDENT_NAME,
3736
INCIDENT_NAME_WITH_ENGAGEMENT,
37+
INCIDENT_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN,
3838
INCIDENT_NEW_ROLE_NOTIFICATION,
3939
INCIDENT_NOTIFICATION,
4040
INCIDENT_NOTIFICATION_COMMON,
4141
INCIDENT_OPEN_TASKS,
42-
INCIDENT_PARTICIPANT_SUGGESTED_READING_ITEM,
4342
INCIDENT_PRIORITY_CHANGE,
4443
INCIDENT_REVIEW_DOCUMENT,
4544
INCIDENT_SEVERITY_CHANGE,
4645
INCIDENT_STATUS_CHANGE,
47-
INCIDENT_TYPE_CHANGE,
48-
INCIDENT_COMPLETED_FORM_MESSAGE,
4946
INCIDENT_TASK_ADD_TO_INCIDENT,
50-
INCIDENT_NAME_WITH_ENGAGEMENT_NO_SELF_JOIN,
47+
INCIDENT_TYPE_CHANGE,
5148
MessageType,
5249
generate_welcome_message,
5350
)
51+
from dispatch.notification import service as notification_service
5452
from dispatch.participant import service as participant_service
5553
from dispatch.participant_role import service as participant_role_service
5654
from dispatch.plugin import service as plugin_service
5755
from dispatch.plugins.dispatch_slack.enums import SlackAPIErrorCode
58-
from dispatch.types import Subject
5956
from dispatch.task.models import TaskCreate
60-
57+
from dispatch.types import Subject
6158

6259
log = logging.getLogger(__name__)
6360

@@ -322,59 +319,6 @@ def send_incident_welcome_participant_messages(
322319
log.debug(f"Welcome participant messages sent {participant_email}.")
323320

324321

325-
@timer
326-
def get_suggested_document_items(incident: Incident, db_session: SessionLocal):
327-
"""Create the suggested document item message."""
328-
suggested_documents = get_suggested_documents(db_session, incident)
329-
330-
items = []
331-
if suggested_documents:
332-
# we send the ephemeral message
333-
# lets grab the first 5 documents
334-
# TODO add more intelligent ranking
335-
for i in suggested_documents[:5]:
336-
description = i.description
337-
if not description:
338-
if i.incident:
339-
description = i.incident.title
340-
341-
items.append({"name": i.name, "weblink": i.weblink, "description": description})
342-
return items
343-
344-
345-
@timer
346-
def send_incident_suggested_reading_messages(
347-
incident: Incident, items: list, participant_email: str, db_session: SessionLocal
348-
):
349-
"""Sends a suggested reading message to a participant."""
350-
if not items:
351-
return
352-
353-
if not incident.conversation:
354-
log.warning(
355-
"Incident suggested reading message not sent. No conversation available for this incident."
356-
)
357-
return
358-
359-
plugin = plugin_service.get_active_instance(
360-
db_session=db_session, project_id=incident.project.id, plugin_type="conversation"
361-
)
362-
if not plugin:
363-
log.warning("Incident suggested reading message not sent. No conversation plugin enabled.")
364-
return
365-
366-
plugin.instance.send_ephemeral(
367-
incident.conversation.channel_id,
368-
participant_email,
369-
"Suggested Reading",
370-
[INCIDENT_PARTICIPANT_SUGGESTED_READING_ITEM],
371-
MessageType.incident_participant_suggested_reading,
372-
items=items,
373-
)
374-
375-
log.debug(f"Suggested reading ephemeral message sent to {participant_email}.")
376-
377-
378322
def send_incident_created_notifications(incident: Incident, db_session: SessionLocal):
379323
"""Sends incident created notifications."""
380324
notification_template = INCIDENT_NOTIFICATION.copy()

src/dispatch/plugins/bases/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from .conversation import ConversationPlugin # noqa
77
from .definition import DefinitionPlugin # noqa
88
from .document import DocumentPlugin # noqa
9-
from .document_resolver import DocumentResolverPlugin # noqa
109
from .email import EmailPlugin # noqa
1110
from .monitor import MonitorPlugin # noqa
1211
from .oncall import OncallPlugin # noqa

src/dispatch/plugins/bases/document_resolver.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/dispatch/plugins/dispatch_core/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import logging
2-
from dispatch.config import BaseConfigurationModel
32

4-
from starlette.config import Config
53
from pydantic import Field
4+
from starlette.config import Config
65

7-
log = logging.getLogger(__name__)
6+
from dispatch.config import BaseConfigurationModel
87

8+
log = logging.getLogger(__name__)
99

1010
config = Config(".env")
1111

src/dispatch/plugins/dispatch_core/plugin.py

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
from fastapi.security.utils import get_authorization_scheme_param
1818
from jose import JWTError, jwt
1919
from jose.exceptions import JWKError
20+
from sqlalchemy.orm import Session
2021
from starlette.requests import Request
2122
from starlette.status import HTTP_401_UNAUTHORIZED
22-
from sqlalchemy.orm import Session
2323

24-
from dispatch.auth.models import MfaChallenge, MfaPayload, DispatchUser, MfaChallengeStatus
24+
from dispatch.auth.models import DispatchUser, MfaChallenge, MfaChallengeStatus, MfaPayload
2525
from dispatch.case import service as case_service
2626
from dispatch.config import (
2727
DISPATCH_AUTHENTICATION_PROVIDER_HEADER_NAME,
@@ -33,36 +33,33 @@
3333
DISPATCH_UI_URL,
3434
)
3535
from dispatch.database.core import Base
36-
from dispatch.document.models import Document, DocumentRead
3736
from dispatch.incident import service as incident_service
38-
from dispatch.incident.models import Incident
3937
from dispatch.individual import service as individual_service
4038
from dispatch.individual.models import IndividualContact, IndividualContactRead
4139
from dispatch.plugin import service as plugin_service
4240
from dispatch.plugins import dispatch_core as dispatch_plugin
4341
from dispatch.plugins.bases import (
4442
AuthenticationProviderPlugin,
4543
ContactPlugin,
46-
DocumentResolverPlugin,
4744
MultiFactorAuthenticationPlugin,
4845
ParticipantPlugin,
4946
TicketPlugin,
5047
)
48+
from dispatch.plugins.dispatch_core.config import DispatchTicketConfiguration
5149
from dispatch.plugins.dispatch_core.exceptions import (
52-
InvalidChallengeError,
53-
UserMismatchError,
5450
ActionMismatchError,
5551
ExpiredChallengeError,
52+
InvalidChallengeError,
5653
InvalidChallengeStateError,
54+
UserMismatchError,
5755
)
56+
from dispatch.plugins.dispatch_core.service import create_resource_id
5857
from dispatch.project import service as project_service
5958
from dispatch.route import service as route_service
6059
from dispatch.service import service as service_service
6160
from dispatch.service.models import Service, ServiceRead
6261
from dispatch.team import service as team_service
6362
from dispatch.team.models import TeamContact, TeamContactRead
64-
from dispatch.plugins.dispatch_core.config import DispatchTicketConfiguration
65-
from dispatch.plugins.dispatch_core.service import create_resource_id
6663

6764
log = logging.getLogger(__name__)
6865

@@ -289,30 +286,6 @@ def create_task_ticket(
289286
}
290287

291288

292-
class DispatchDocumentResolverPlugin(DocumentResolverPlugin):
293-
title = "Dispatch Plugin - Document Resolver"
294-
slug = "dispatch-document-resolver"
295-
description = "Uses dispatch itself to resolve incident documents."
296-
version = dispatch_plugin.__version__
297-
298-
author = "Netflix"
299-
author_url = "https://github.com/netflix/dispatch.git"
300-
301-
def get(
302-
self,
303-
incident: Incident,
304-
db_session=None,
305-
):
306-
"""Fetches documents from Dispatch."""
307-
recommendation = route_service.get(
308-
db_session=db_session,
309-
project_id=incident.project_id,
310-
class_instance=incident,
311-
models=[(Document, DocumentRead)],
312-
)
313-
return recommendation.matches
314-
315-
316289
class DispatchMfaPlugin(MultiFactorAuthenticationPlugin):
317290
title = "Dispatch Plugin - Multi Factor Authentication"
318291
slug = "dispatch-auth-mfa"

0 commit comments

Comments
 (0)