diff --git a/src/dispatch/plugins/dispatch_slack/plugin.py b/src/dispatch/plugins/dispatch_slack/plugin.py index 55320cc5e3e1..913cf2cfeaf6 100644 --- a/src/dispatch/plugins/dispatch_slack/plugin.py +++ b/src/dispatch/plugins/dispatch_slack/plugin.py @@ -205,8 +205,10 @@ def send_direct( blocks: Optional[List] = None, **kwargs, ): - """Sends a message directly to a user.""" + """Sends a message directly to a user if the user exists.""" client = create_slack_client(self.configuration) + if not does_user_exist(client, user): + return {} user_id = resolve_user(client, user)["id"] if not blocks: @@ -227,8 +229,10 @@ def send_ephemeral( blocks: Optional[List] = None, **kwargs, ): - """Sends an ephemeral message to a user in a channel.""" + """Sends an ephemeral message to a user in a channel if the user exists.""" client = create_slack_client(self.configuration) + if not does_user_exist(client, user): + return {} user_id = resolve_user(client, user)["id"] if not blocks: