Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ You can override their values if you wish to do so. Included below are their des
| `/dispatch-list-incidents <organization-slug\|'default'> <project-slug\|'default'>` | Lists current active and stable incidents and closed incidents in the last 24 hours. |
| `/dispatch-list-my-tasks` | Opens a modal with the list of your open and resolved incident tasks. |
| `/dispatch-list-participants` | Opens a modal with the list of incident participants. |
| `/dispatch-list-resources` | Opens a modal with the list of all incident resources. |
| `/dispatch-list-tasks` | Opens a modal with the list of open and resolved incident tasks. |
| `/dispatch-list-workflows` | List workflows previously run during this incident. |
| `/dispatch-report-executive` | Opens a modal to write an executive report. |
Expand Down
1 change: 0 additions & 1 deletion docs/user-guide/incident-commander.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ All Slack commands are listed below, or you may view _groups_ of commands relati
- [`/dispatch-engage-oncall`](#%2Fdispatch-engage-oncall)
- [`/dispatch-list-my-tasks`](#%2Fdispatch-list-my-tasks)
- [`/dispatch-list-participants`](#%2Fdispatch-list-participants)
- [`/dispatch-list-resources`](#%2Fdispatch-list-resources)
- [`/dispatch-list-tasks`](#%2Fdispatch-list-tasks)
- [`/dispatch-list-workflows`](#%2Fdispatch-list-workflows)
- [`/dispatch-list-incidents`](#%2Fdispatch-list-incidents)
Expand Down
1 change: 0 additions & 1 deletion src/dispatch/conversation/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ConversationCommands(DispatchEnum):
engage_oncall = "engage-oncall"
executive_report = "executive-report"
list_participants = "list-participants"
list_resources = "list-resources"
list_tasks = "list-tasks"
report_incident = "report-incident"
tactical_report = "tactical-report"
Expand Down
66 changes: 0 additions & 66 deletions src/dispatch/incident/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
INCIDENT_PARTICIPANT_SUGGESTED_READING_ITEM,
INCIDENT_PARTICIPANT_WELCOME_MESSAGE,
INCIDENT_PRIORITY_CHANGE,
INCIDENT_RESOURCES_MESSAGE,
INCIDENT_REVIEW_DOCUMENT,
INCIDENT_SEVERITY_CHANGE,
INCIDENT_STATUS_CHANGE,
Expand Down Expand Up @@ -724,71 +723,6 @@ def send_incident_review_document_notification(
log.debug("Incident review document notification sent.")


def send_incident_resources_ephemeral_message_to_participant(
user_id: str, incident: Incident, db_session: SessionLocal
):
"""Sends the list of incident resources to the participant via an ephemeral message."""
plugin = plugin_service.get_active_instance(
db_session=db_session, project_id=incident.project.id, plugin_type="conversation"
)
if not plugin:
log.warning("Incident resource message not sent, no conversation plugin enabled.")
return

incident_description = (
incident.description
if len(incident.description) <= 500
else f"{incident.description[:500]}..."
)

message_kwargs = {
"title": incident.title,
"description": incident_description,
"commander_fullname": incident.commander.individual.name,
"commander_team": incident.commander.team,
"commander_weblink": incident.commander.individual.weblink,
"reporter_fullname": incident.reporter.individual.name,
"reporter_team": incident.reporter.team,
"reporter_weblink": incident.reporter.individual.weblink,
"document_weblink": resolve_attr(incident, "incident_document.weblink"),
"storage_weblink": resolve_attr(incident, "storage.weblink"),
"ticket_weblink": resolve_attr(incident, "ticket.weblink"),
"conference_weblink": resolve_attr(incident, "conference.weblink"),
"conference_challenge": resolve_attr(incident, "conference.conference_challenge"),
}

if incident.incident_review_document:
message_kwargs.update(
{"review_document_weblink": incident.incident_review_document.weblink}
)

faq_doc = document_service.get_incident_faq_document(
db_session=db_session, project_id=incident.project_id
)
if faq_doc:
message_kwargs.update({"faq_weblink": faq_doc.weblink})

conversation_reference = document_service.get_conversation_reference_document(
db_session=db_session, project_id=incident.project_id
)
if conversation_reference:
message_kwargs.update(
{"conversation_commands_reference_document_weblink": conversation_reference.weblink}
)

# we send the ephemeral message
plugin.instance.send_ephemeral(
incident.conversation.channel_id,
user_id,
"Incident Resources Message",
INCIDENT_RESOURCES_MESSAGE,
MessageType.incident_resources_message,
**message_kwargs,
)

log.debug(f"List of incident resources sent to {user_id} via ephemeral message.")


def send_incident_close_reminder(incident: Incident, db_session: SessionLocal):
"""
Sends a direct message to the incident commander reminding
Expand Down
17 changes: 1 addition & 16 deletions src/dispatch/messaging/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from dispatch.conversation.enums import ConversationButtonActions
from dispatch.incident.enums import IncidentStatus
from dispatch.case.enums import CaseStatus

from dispatch.enums import DispatchEnum, DocumentResourceTypes, DocumentResourceReferenceTypes

Expand All @@ -23,7 +22,6 @@ class MessageType(DispatchEnum):
incident_participant_suggested_reading = "incident-participant-suggested-reading"
incident_participant_welcome = "incident-participant-welcome"
incident_rating_feedback = "incident-rating-feedback"
incident_resources_message = "incident-resources-message"
incident_status_reminder = "incident-status-reminder"
incident_tactical_report = "incident-tactical-report"
incident_task_list = "incident-task-list"
Expand Down Expand Up @@ -299,7 +297,7 @@ class MessageType(DispatchEnum):
\n • Keep the incident and its status up to date using the Slack `{{update_command}}` command.
\n • Invite incident participants and team oncalls by mentioning them in the incident channel or using the Slack `{{engage_oncall_command}}` command.
\n • Keep incident participants and stakeholders informed by creating tactical and executive reports using the `{{tactical_report_command}}` and `{{executive_report_command}}` commands.
\n • Get links to all incident resources including the Slack commands reference sheet and Security Incident Response FAQ by running the `{{list_resources_command}}` command.
\n • Get links to incident resources from the <{{dispatch_ui_incident_url}}|Dispatch Web UI> or bookmarks in the incident conversation.
\n
To find a Slack command, simply type `/` in the message field or click the lightning bolt icon to the left of the message field.
"""
Expand Down Expand Up @@ -490,19 +488,6 @@ class MessageType(DispatchEnum):
INCIDENT_FAQ_DOCUMENT,
]

INCIDENT_RESOURCES_MESSAGE = [
INCIDENT_TITLE,
INCIDENT_DESCRIPTION,
INCIDENT_REPORTER,
INCIDENT_COMMANDER,
INCIDENT_INVESTIGATION_DOCUMENT,
INCIDENT_REVIEW_DOCUMENT,
INCIDENT_STORAGE,
INCIDENT_CONFERENCE,
INCIDENT_CONVERSATION_COMMANDS_REFERENCE_DOCUMENT,
INCIDENT_FAQ_DOCUMENT,
]

INCIDENT_NOTIFICATION_COMMON = [INCIDENT_TITLE]

INCIDENT_NOTIFICATION = INCIDENT_NOTIFICATION_COMMON.copy()
Expand Down
5 changes: 0 additions & 5 deletions src/dispatch/plugins/dispatch_slack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ class SlackConversationConfiguration(SlackConfiguration):
title="Engage Oncall Command String",
description="Defines the string used to engage an oncall. Must match what is defined in Slack.",
)
slack_command_list_resources: str = Field(
"/dispatch-list-resources",
title="List Resources Command String",
description="Defines the string used to list incident resources. Must match what is defined in Slack.",
)
slack_command_report_incident: str = Field(
"/dispatch-report-incident",
title="Report Incident Command String",
Expand Down
77 changes: 5 additions & 72 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
from datetime import datetime
from typing import Any

import logging
import pytz

from blockkit import (
Actions,
Button,
Expand All @@ -22,16 +22,13 @@
from slack_bolt import Ack, BoltContext, BoltRequest, Respond
from slack_sdk.errors import SlackApiError
from slack_sdk.web.client import WebClient

from sqlalchemy import func
from sqlalchemy.orm import Session

from dispatch.auth.models import DispatchUser
from dispatch.config import DISPATCH_UI_URL

# from dispatch.database.core import resolve_attr
from dispatch.database.service import search_filter_sort_paginate

# from dispatch.document import service as document_service
from dispatch.enums import Visibility
from dispatch.event import service as event_service
from dispatch.exceptions import DispatchException
Expand All @@ -41,8 +38,6 @@
from dispatch.incident.models import IncidentCreate, IncidentRead, IncidentUpdate
from dispatch.individual import service as individual_service
from dispatch.individual.models import IndividualContactRead

# from dispatch.messaging.strings import INCIDENT_RESOURCES_MESSAGE, MessageType
from dispatch.monitor import service as monitor_service
from dispatch.monitor.models import MonitorCreate
from dispatch.nlp import build_phrase_matcher, build_term_vocab, extract_terms_from_text
Expand All @@ -55,6 +50,8 @@
from dispatch.plugins.dispatch_slack.bolt import app
from dispatch.plugins.dispatch_slack.decorators import message_dispatcher
from dispatch.plugins.dispatch_slack.exceptions import CommandError
from dispatch.plugins.dispatch_slack.models import MonitorMetadata, TaskMetadata
from dispatch.plugins.dispatch_slack.service import get_user_email, get_user_profile_by_email
from dispatch.plugins.dispatch_slack.fields import (
DefaultActionIds,
DefaultBlockIds,
Expand Down Expand Up @@ -96,8 +93,6 @@
UpdateParticipantActions,
UpdateParticipantBlockIds,
)

# from dispatch.plugins.dispatch_slack.messaging import create_message_blocks
from dispatch.plugins.dispatch_slack.middleware import (
action_context_middleware,
button_context_middleware,
Expand All @@ -112,8 +107,6 @@
subject_middleware,
user_middleware,
)
from dispatch.plugins.dispatch_slack.models import MonitorMetadata, TaskMetadata
from dispatch.plugins.dispatch_slack.service import get_user_email, get_user_profile_by_email
from dispatch.project import service as project_service
from dispatch.report import flows as report_flows
from dispatch.report import service as report_service
Expand Down Expand Up @@ -151,10 +144,6 @@ def configure(config):
command_context_middleware,
]

app.command(config.slack_command_list_resources, middleware=middleware)(
handle_list_resources_command
)

middleware = [
subject_middleware,
configuration_middleware,
Expand Down Expand Up @@ -638,62 +627,6 @@ def draw_task_modal(
client.views_update(view_id=view_id, view=modal)


# NOTE: This command has been deprecated in favor of channel bookmarks and its code will be removed in Q1 2023.
def handle_list_resources_command(
ack: Ack, db_session: Session, context: BoltContext, respond: Respond
) -> None:
"""Handles the list resources command."""
ack()

# incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id)
#
# incident_description = (
# incident.description
# if len(incident.description) <= 500
# else f"{incident.description[:500]}..."
# )
#
# # we send the ephemeral message
# message_kwargs = {
# "title": incident.title,
# "description": incident_description,
# "commander_fullname": incident.commander.individual.name,
# "commander_team": incident.commander.team,
# "commander_weblink": incident.commander.individual.weblink,
# "reporter_fullname": incident.reporter.individual.name,
# "reporter_team": incident.reporter.team,
# "reporter_weblink": incident.reporter.individual.weblink,
# "document_weblink": resolve_attr(incident, "incident_document.weblink"),
# "storage_weblink": resolve_attr(incident, "storage.weblink"),
# "conference_weblink": resolve_attr(incident, "conference.weblink"),
# "conference_challenge": resolve_attr(incident, "conference.conference_challenge"),
# }
#
# faq_doc = document_service.get_incident_faq_document(
# db_session=db_session, project_id=incident.project_id
# )
# if faq_doc:
# message_kwargs.update({"faq_weblink": faq_doc.weblink})
#
# conversation_reference = document_service.get_conversation_reference_document(
# db_session=db_session, project_id=incident.project_id
# )
# if conversation_reference:
# message_kwargs.update(
# {"conversation_commands_reference_document_weblink": conversation_reference.weblink}
# )
#
# blocks = create_message_blocks(
# INCIDENT_RESOURCES_MESSAGE, MessageType.incident_resources_message, **message_kwargs
# )
#
# blocks = Message(blocks=blocks).build()["blocks"]
# respond(text="Incident Resources", blocks=blocks, response_type="ephemeral")

message = "This slash command has been deprecated in favor of channel bookmarks. You can find all incident resources bookmarked in the channel."
respond(text=message, response_type="ephemeral", replace_original=False, delete_original=False)


# EVENTS


Expand Down
4 changes: 0 additions & 4 deletions src/dispatch/plugins/dispatch_slack/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ def get_incident_conversation_command_message(
"response_type": "ephemeral",
"text": "Opening a dialog to engage an oncall person...",
},
config.slack_command_list_resources: {
"response_type": "ephemeral",
"text": "Fetching the list of incident resources...",
},
config.slack_command_report_incident: {
"response_type": "ephemeral",
"text": "Opening a dialog to report an incident...",
Expand Down
3 changes: 1 addition & 2 deletions src/dispatch/plugins/dispatch_slack/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
)

from .case.messages import create_case_message, create_signal_messages
from .endpoints import router as slack_event_router

from .endpoints import router as slack_event_router
from .messaging import create_message_blocks
from .service import (
add_users_to_conversation_thread,
Expand Down Expand Up @@ -232,7 +232,6 @@ def get_command_name(self, command: str):
ConversationCommands.engage_oncall: self.configuration.slack_command_engage_oncall,
ConversationCommands.executive_report: self.configuration.slack_command_report_executive,
ConversationCommands.list_participants: self.configuration.slack_command_list_participants,
ConversationCommands.list_resources: self.configuration.slack_command_list_resources,
ConversationCommands.list_tasks: self.configuration.slack_command_list_tasks,
ConversationCommands.tactical_report: self.configuration.slack_command_report_tactical,
}
Expand Down