Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add welcome ephemeral message to dedicated channel cases #4700

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion src/dispatch/plugins/dispatch_slack/case/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
from dispatch.plugins.dispatch_slack.case.messages import (
create_case_message,
create_signal_engagement_message,
create_welcome_ephemeral_message_to_participant,
)
from dispatch.plugins.dispatch_slack.config import SlackConversationConfiguration
from dispatch.plugins.dispatch_slack.decorators import message_dispatcher
Expand Down Expand Up @@ -940,15 +941,25 @@ def handle_new_participant_added(
participants = re.findall(r"\<\@([a-zA-Z0-9]*)\>", payload["text"])
for user_id in participants:
try:
case: Case = context["subject"]
user_email = get_user_email(client=client, user_id=user_id)

participant = case_flows.case_add_or_reactivate_participant_flow(
case_id=context["subject"].id,
case_id=case.id,
user_email=user_email,
db_session=db_session,
add_to_conversation=False,
)
participant.user_conversation_id = user_id
if case.dedicated_channel:
welcome_message = create_welcome_ephemeral_message_to_participant(
case=context["subject"]
wssheldon marked this conversation as resolved.
Show resolved Hide resolved
)
client.chat_postEphemeral(
text=welcome_message,
channel=payload["channel"],
user=payload["user"],
)
except Exception as e:
log.warn(f"Error adding participant {user_id} to Case {context['subject'].id}: {e}")
continue
Expand Down
33 changes: 33 additions & 0 deletions src/dispatch/plugins/dispatch_slack/case/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,36 @@ def create_signal_engagement_message(
)

return Message(blocks=blocks).build()["blocks"]


def create_welcome_ephemeral_message_to_participant(case: Case) -> Message:
blocks = [
Section(
text="You've been added to this case, because we think you may be able to help resolve it. Please review the case details below and reach out to the case assignee if you have any questions.",
),
Section(
text=f"*Title* \n {case.title}",
),
Section(
text=f"*Description* \n {case.description}",
),
Section(
text=f"*Visibility - {case.visibility}*",
),
Section(
text=f"*Status - {case.status}*",
),
Section(
text=f"*Type - {case.case_type.name}*",
),
Section(
text=f"*Severity - {case.case_severity.name}*",
),
Section(
text=f"*Priority - {case.case_priority.name}*",
),
Section(
text=f"*Reporter - {case.reporter.individual.name}*",
),
]
return Message(blocks=blocks).build()["blocks"]
Loading