From 6374d53b877cedea18c8e3070918822f7ff04dd2 Mon Sep 17 00:00:00 2001 From: Avery Date: Wed, 26 Jun 2024 13:03:16 -0700 Subject: [PATCH] Adds additional bot check. (#4884) * Adds additional bot check. * Fixes placement of users_info API call * Update src/dispatch/plugins/dispatch_slack/middleware.py Co-authored-by: Jason Schroth * Update src/dispatch/plugins/dispatch_slack/middleware.py Co-authored-by: Jason Schroth * Update src/dispatch/plugins/dispatch_slack/middleware.py Co-authored-by: Jason Schroth --------- Co-authored-by: Jason Schroth --- src/dispatch/plugins/dispatch_slack/middleware.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dispatch/plugins/dispatch_slack/middleware.py b/src/dispatch/plugins/dispatch_slack/middleware.py index a03f141359a9..743485803d98 100644 --- a/src/dispatch/plugins/dispatch_slack/middleware.py +++ b/src/dispatch/plugins/dispatch_slack/middleware.py @@ -284,7 +284,12 @@ def user_middleware( user_in=UserRegister(email=participant.individual.email), ) else: - email = client.users_info(user=user_id)["user"]["profile"]["email"] + user_info = client.users_info(user=user_id).get("user", {}) + + if user_info.get("is_bot", False): + return context.ack() + + email = user_info.get("profile", {}).get("email") if not email: raise ContextError("Unable to get user email address.")