|
1 | | -import logging |
2 | 1 | from datetime import datetime |
3 | 2 | from typing import Any |
4 | | - |
| 3 | +import logging |
5 | 4 | import pytz |
| 5 | + |
6 | 6 | from blockkit import ( |
7 | 7 | Actions, |
8 | 8 | Button, |
|
22 | 22 | from slack_bolt import Ack, BoltContext, BoltRequest, Respond |
23 | 23 | from slack_sdk.errors import SlackApiError |
24 | 24 | from slack_sdk.web.client import WebClient |
| 25 | + |
25 | 26 | from sqlalchemy import func |
26 | 27 | from sqlalchemy.orm import Session |
27 | 28 |
|
28 | 29 | from dispatch.auth.models import DispatchUser |
29 | 30 | from dispatch.config import DISPATCH_UI_URL |
30 | | - |
31 | | -# from dispatch.database.core import resolve_attr |
32 | 31 | from dispatch.database.service import search_filter_sort_paginate |
33 | | - |
34 | | -# from dispatch.document import service as document_service |
35 | 32 | from dispatch.enums import Visibility |
36 | 33 | from dispatch.event import service as event_service |
37 | 34 | from dispatch.exceptions import DispatchException |
|
41 | 38 | from dispatch.incident.models import IncidentCreate, IncidentRead, IncidentUpdate |
42 | 39 | from dispatch.individual import service as individual_service |
43 | 40 | from dispatch.individual.models import IndividualContactRead |
44 | | - |
45 | | -# from dispatch.messaging.strings import INCIDENT_RESOURCES_MESSAGE, MessageType |
46 | 41 | from dispatch.monitor import service as monitor_service |
47 | 42 | from dispatch.monitor.models import MonitorCreate |
48 | 43 | from dispatch.nlp import build_phrase_matcher, build_term_vocab, extract_terms_from_text |
|
55 | 50 | from dispatch.plugins.dispatch_slack.bolt import app |
56 | 51 | from dispatch.plugins.dispatch_slack.decorators import message_dispatcher |
57 | 52 | from dispatch.plugins.dispatch_slack.exceptions import CommandError |
| 53 | +from dispatch.plugins.dispatch_slack.models import MonitorMetadata, TaskMetadata |
| 54 | +from dispatch.plugins.dispatch_slack.service import get_user_email, get_user_profile_by_email |
58 | 55 | from dispatch.plugins.dispatch_slack.fields import ( |
59 | 56 | DefaultActionIds, |
60 | 57 | DefaultBlockIds, |
|
96 | 93 | UpdateParticipantActions, |
97 | 94 | UpdateParticipantBlockIds, |
98 | 95 | ) |
99 | | - |
100 | | -# from dispatch.plugins.dispatch_slack.messaging import create_message_blocks |
101 | 96 | from dispatch.plugins.dispatch_slack.middleware import ( |
102 | 97 | action_context_middleware, |
103 | 98 | button_context_middleware, |
|
112 | 107 | subject_middleware, |
113 | 108 | user_middleware, |
114 | 109 | ) |
115 | | -from dispatch.plugins.dispatch_slack.models import MonitorMetadata, TaskMetadata |
116 | | -from dispatch.plugins.dispatch_slack.service import get_user_email, get_user_profile_by_email |
117 | 110 | from dispatch.project import service as project_service |
118 | 111 | from dispatch.report import flows as report_flows |
119 | 112 | from dispatch.report import service as report_service |
@@ -151,10 +144,6 @@ def configure(config): |
151 | 144 | command_context_middleware, |
152 | 145 | ] |
153 | 146 |
|
154 | | - app.command(config.slack_command_list_resources, middleware=middleware)( |
155 | | - handle_list_resources_command |
156 | | - ) |
157 | | - |
158 | 147 | middleware = [ |
159 | 148 | subject_middleware, |
160 | 149 | configuration_middleware, |
@@ -638,62 +627,6 @@ def draw_task_modal( |
638 | 627 | client.views_update(view_id=view_id, view=modal) |
639 | 628 |
|
640 | 629 |
|
641 | | -# NOTE: This command has been deprecated in favor of channel bookmarks and its code will be removed in Q1 2023. |
642 | | -def handle_list_resources_command( |
643 | | - ack: Ack, db_session: Session, context: BoltContext, respond: Respond |
644 | | -) -> None: |
645 | | - """Handles the list resources command.""" |
646 | | - ack() |
647 | | - |
648 | | - # incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id) |
649 | | - # |
650 | | - # incident_description = ( |
651 | | - # incident.description |
652 | | - # if len(incident.description) <= 500 |
653 | | - # else f"{incident.description[:500]}..." |
654 | | - # ) |
655 | | - # |
656 | | - # # we send the ephemeral message |
657 | | - # message_kwargs = { |
658 | | - # "title": incident.title, |
659 | | - # "description": incident_description, |
660 | | - # "commander_fullname": incident.commander.individual.name, |
661 | | - # "commander_team": incident.commander.team, |
662 | | - # "commander_weblink": incident.commander.individual.weblink, |
663 | | - # "reporter_fullname": incident.reporter.individual.name, |
664 | | - # "reporter_team": incident.reporter.team, |
665 | | - # "reporter_weblink": incident.reporter.individual.weblink, |
666 | | - # "document_weblink": resolve_attr(incident, "incident_document.weblink"), |
667 | | - # "storage_weblink": resolve_attr(incident, "storage.weblink"), |
668 | | - # "conference_weblink": resolve_attr(incident, "conference.weblink"), |
669 | | - # "conference_challenge": resolve_attr(incident, "conference.conference_challenge"), |
670 | | - # } |
671 | | - # |
672 | | - # faq_doc = document_service.get_incident_faq_document( |
673 | | - # db_session=db_session, project_id=incident.project_id |
674 | | - # ) |
675 | | - # if faq_doc: |
676 | | - # message_kwargs.update({"faq_weblink": faq_doc.weblink}) |
677 | | - # |
678 | | - # conversation_reference = document_service.get_conversation_reference_document( |
679 | | - # db_session=db_session, project_id=incident.project_id |
680 | | - # ) |
681 | | - # if conversation_reference: |
682 | | - # message_kwargs.update( |
683 | | - # {"conversation_commands_reference_document_weblink": conversation_reference.weblink} |
684 | | - # ) |
685 | | - # |
686 | | - # blocks = create_message_blocks( |
687 | | - # INCIDENT_RESOURCES_MESSAGE, MessageType.incident_resources_message, **message_kwargs |
688 | | - # ) |
689 | | - # |
690 | | - # blocks = Message(blocks=blocks).build()["blocks"] |
691 | | - # respond(text="Incident Resources", blocks=blocks, response_type="ephemeral") |
692 | | - |
693 | | - message = "This slash command has been deprecated in favor of channel bookmarks. You can find all incident resources bookmarked in the channel." |
694 | | - respond(text=message, response_type="ephemeral", replace_original=False, delete_original=False) |
695 | | - |
696 | | - |
697 | 630 | # EVENTS |
698 | 631 |
|
699 | 632 |
|
|
0 commit comments