From e1b79e1a38540ee17bbfa4e31771e08f94921c66 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Mon, 4 Nov 2024 16:39:32 -0800 Subject: [PATCH 1/2] Fixing form_data to use participant id --- .../plugins/dispatch_slack/case/interactive.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/dispatch/plugins/dispatch_slack/case/interactive.py b/src/dispatch/plugins/dispatch_slack/case/interactive.py index ec8520cf2841..c44458e89d34 100644 --- a/src/dispatch/plugins/dispatch_slack/case/interactive.py +++ b/src/dispatch/plugins/dispatch_slack/case/interactive.py @@ -402,18 +402,21 @@ def engage( """Handles the engage user action.""" ack() - if form_data.get(DefaultBlockIds.participant_select): - user_email = client.users_info(user=form_data[DefaultBlockIds.participant_select]["value"])[ - "user" - ]["profile"]["email"] + if form_data.get(DefaultBlockIds.description_input): + participant_id = form_data[DefaultBlockIds.participant_select]["value"] + participant = participant_service.get(db_session=db_session, participant_id=participant_id) + if participant: + user_email = participant.individual.email + else: + log.error(f"Participant not found for id {participant_id} when trying to engage user") + return else: - # TODO: log error return if form_data.get(DefaultBlockIds.description_input): engagement = form_data[DefaultBlockIds.description_input] else: - # TODO log error + log.warning("Engagement text not found") return case = case_service.get(db_session=db_session, case_id=context["subject"].id) From 0ea0423ac00641aeef1b07f493d2b58e400fe87f Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Mon, 4 Nov 2024 16:40:26 -0800 Subject: [PATCH 2/2] Using correct form_data key --- src/dispatch/plugins/dispatch_slack/case/interactive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dispatch/plugins/dispatch_slack/case/interactive.py b/src/dispatch/plugins/dispatch_slack/case/interactive.py index c44458e89d34..70215a569725 100644 --- a/src/dispatch/plugins/dispatch_slack/case/interactive.py +++ b/src/dispatch/plugins/dispatch_slack/case/interactive.py @@ -402,7 +402,7 @@ def engage( """Handles the engage user action.""" ack() - if form_data.get(DefaultBlockIds.description_input): + if form_data.get(DefaultBlockIds.participant_select): participant_id = form_data[DefaultBlockIds.participant_select]["value"] participant = participant_service.get(db_session=db_session, participant_id=participant_id) if participant: