From 85f9b0f168a5c6469374e75141604967b3a18147 Mon Sep 17 00:00:00 2001 From: Innokentii Konstantinov Date: Mon, 27 Nov 2023 18:36:53 +0800 Subject: [PATCH] Log slack bot_id and bot_user_it (#3429) Log slack bot id and bot user id to check if we can avoid request to slack api --- docs/sources/get-started/_index.md | 1 + engine/apps/slack/views.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/sources/get-started/_index.md b/docs/sources/get-started/_index.md index b81760b4..332726b9 100644 --- a/docs/sources/get-started/_index.md +++ b/docs/sources/get-started/_index.md @@ -128,6 +128,7 @@ re-launch Escalation Chain and move Alert Group * **Resolved:** Similar to "Acknowledged". **Possible transitions**: + * Firing -> Acknowledged * Firing -> Silenced * Firing -> Resolved diff --git a/engine/apps/slack/views.py b/engine/apps/slack/views.py index 60a2ebee..48b065b2 100644 --- a/engine/apps/slack/views.py +++ b/engine/apps/slack/views.py @@ -222,6 +222,20 @@ class SlackEventApiEndpointView(APIView): response = sc.bots_info(bot=payload_event_bot_id) bot_user_id = response.get("bot", {}).get("user_id", "") + # test if we can use user from authorizations instead of api call + payload_bot_user_id = payload_event.get("authorizations", {}).get("user_id") + logger.info( + f"checkin_bot_user_id equal={payload_bot_user_id==slack_team_identity.bot_user_id}" + f" payload_bot_user_id={payload_bot_user_id} reqiest_bot_user_id={bot_user_id}" + f" sti_bot_user_id={slack_team_identity.bot_user_id}" + ) + + # test if we can use bot_id instead of api call + logger.info( + f"checking_bot_id equal={payload_event_bot_id == slack_team_identity.bot_id}" + f" payload_bot_id={payload_event_bot_id} sti_bot_id={slack_team_identity.bot_id}" + ) + # Don't react on own bot's messages. if bot_user_id == slack_team_identity.bot_user_id: return Response(status=200)