From 4b746369e84f6b428fcb9c1da87720a85d5b85d8 Mon Sep 17 00:00:00 2001 From: Colin Chung Date: Thu, 4 Apr 2024 16:48:22 -0700 Subject: [PATCH] [INTPROD-9204] Add Auth-Test Call --- omnibot/services/slack/__init__.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/omnibot/services/slack/__init__.py b/omnibot/services/slack/__init__.py index 947f359..61801aa 100644 --- a/omnibot/services/slack/__init__.py +++ b/omnibot/services/slack/__init__.py @@ -471,6 +471,30 @@ def get_user(bot, user_id): ), ) return {} + + + +def get_auth(bot): + """ + Get the auth info for the bot. + """ + redis_client = omniredis.get_redis_client() + auth_info = redis_client.hget(f"auth:{bot.team.name}", bot.name) + if auth_info: + return json.loads(auth_info) + auth_info = client(bot).api_call("auth.test") + if auth_info["ok"]: + redis_client.hset(f"auth:{bot.team.name}", bot.id, json.dumps(auth_info)) + return auth_info + else: + logger.warning( + "Failed to get auth info", + extra=merge_logging_context( + _get_failure_context(auth_info), + bot.logging_context, + ), + ) + return {} def get_name_from_user(user):