Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INTPROD-9204] Add Auth-Test Call #107

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions omnibot/services/slack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,29 @@ 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):
profile = user.get("profile", {})
name = profile.get("display_name")
Expand Down
Loading