Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Merged
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
32 changes: 31 additions & 1 deletion src/dispatch/plugins/dispatch_slack/case/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Section,
UsersSelect,
)
from slack_bolt import Ack, BoltContext, Respond
from slack_bolt import Ack, BoltContext, Respond, BoltRequest
from slack_sdk.errors import SlackApiError
from slack_sdk.web.client import WebClient
from sqlalchemy.exc import IntegrityError
Expand Down Expand Up @@ -100,6 +100,7 @@
shortcut_context_middleware,
subject_middleware,
user_middleware,
is_bot,
)
from dispatch.plugins.dispatch_slack.modals.common import send_success_modal
from dispatch.plugins.dispatch_slack.models import (
Expand Down Expand Up @@ -1379,6 +1380,35 @@ def handle_case_after_hours_message(
)


@message_dispatcher.add(subject=CaseSubjects.case)
def handle_thread_creation(
ack: Ack,
client: WebClient,
payload: dict,
db_session: Session,
context: BoltContext,
request: BoltRequest,
) -> None:
"""Sends the user an ephemeral message if they use threads in a dedicated case channel."""
ack()

if not context["config"].ban_threads:
return

case = case_service.get(db_session=db_session, case_id=context["subject"].id)
if not case.dedicated_channel:
return

if payload.get("thread_ts") and not is_bot(request):
message = "Please refrain from using threads in case channels. Threads make it harder for case participants to maintain context."
client.chat_postEphemeral(
text=message,
channel=payload["channel"],
thread_ts=payload["thread_ts"],
user=payload["user"],
)


@app.action("button-link")
def ack_button_link(ack: Ack):
"""Handles noop button link action."""
Expand Down
Loading