|
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 |
| -from sqlalchemy import func |
26 | 25 | from sqlalchemy.orm import Session
|
27 | 26 |
|
28 | 27 | from dispatch.auth.models import DispatchUser
|
|
41 | 40 | from dispatch.individual.models import IndividualContactRead
|
42 | 41 | from dispatch.monitor import service as monitor_service
|
43 | 42 | from dispatch.monitor.models import MonitorCreate
|
44 |
| -from dispatch.nlp import build_phrase_matcher, build_term_vocab, extract_terms_from_text |
45 | 43 | from dispatch.participant import service as participant_service
|
46 | 44 | from dispatch.participant.models import ParticipantUpdate
|
47 | 45 | from dispatch.participant_role import service as participant_role_service
|
|
119 | 117 | from dispatch.report.models import ExecutiveReportCreate, TacticalReportCreate
|
120 | 118 | from dispatch.service import service as service_service
|
121 | 119 | from dispatch.tag import service as tag_service
|
122 |
| -from dispatch.tag.models import Tag |
123 | 120 | from dispatch.task import service as task_service
|
124 | 121 | from dispatch.task.enums import TaskStatus
|
125 | 122 | from dispatch.task.models import Task
|
@@ -806,30 +803,6 @@ def handle_thread_creation(
|
806 | 803 | )
|
807 | 804 |
|
808 | 805 |
|
809 |
| -@message_dispatcher.add(subject="incident") |
810 |
| -def handle_message_tagging( |
811 |
| - ack: Ack, db_session: Session, payload: dict, context: BoltContext |
812 |
| -) -> None: |
813 |
| - """Looks for incident tags in incident messages.""" |
814 |
| - ack() |
815 |
| - text = payload["text"] |
816 |
| - incident = incident_service.get(db_session=db_session, incident_id=context["subject"].id) |
817 |
| - tags = tag_service.get_all(db_session=db_session, project_id=incident.project.id).all() |
818 |
| - tag_strings = [t.name.lower() for t in tags if t.discoverable] |
819 |
| - phrases = build_term_vocab(tag_strings) |
820 |
| - matcher = build_phrase_matcher("dispatch-tag", phrases) |
821 |
| - extracted_tags = list(set(extract_terms_from_text(text, matcher))) |
822 |
| - |
823 |
| - matched_tags = ( |
824 |
| - db_session.query(Tag) |
825 |
| - .filter(func.upper(Tag.name).in_([func.upper(t) for t in extracted_tags])) |
826 |
| - .all() |
827 |
| - ) |
828 |
| - |
829 |
| - incident.tags.extend(matched_tags) |
830 |
| - db_session.commit() |
831 |
| - |
832 |
| - |
833 | 806 | @message_dispatcher.add(subject="incident")
|
834 | 807 | def handle_message_monitor(
|
835 | 808 | ack: Ack,
|
|
0 commit comments