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
This commit is contained in:
parent
95a3ab3b75
commit
85f9b0f168
2 changed files with 15 additions and 0 deletions
|
|
@ -128,6 +128,7 @@ re-launch Escalation Chain and move Alert Group
|
|||
* **Resolved:** Similar to "Acknowledged".
|
||||
|
||||
**Possible transitions**:
|
||||
|
||||
* Firing -> Acknowledged
|
||||
* Firing -> Silenced
|
||||
* Firing -> Resolved
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue