Skip to content

Commit

Permalink
micro optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 16, 2024
1 parent a3f196f commit 6dad022
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions superset/views/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
from flask_jwt_extended.exceptions import NoAuthorizationError
from sqlalchemy.orm.exc import NoResultFound

from superset import app
from superset import app, is_feature_enabled
from superset.daos.user import UserDAO
from superset.extensions import feature_flag_manager
from superset.utils.slack import get_user_avatar, SlackClientError
from superset.views.base_api import BaseSupersetApi
from superset.views.users.schemas import UserResponseSchema
Expand Down Expand Up @@ -144,10 +143,12 @@ def avatar(self, user_id: int) -> Response:
# fetch from the one-to-one relationship
if len(user.extra_attributes) > 0:
avatar_url = user.extra_attributes[0].avatar_url
should_fetch_slack_avatar = app.config.get(
"SLACK_API_TOKEN"
) and feature_flag_manager.is_feature_enabled("SLACK_ENABLE_AVATARS")
if not avatar_url and should_fetch_slack_avatar:
slack_token = app.config.get("SLACK_API_TOKEN")
if (
not avatar_url
and slack_token
and is_feature_enabled("SLACK_ENABLE_AVATARS")
):
try:
# Fetching the avatar url from slack
avatar_url = get_user_avatar(user.email)
Expand Down

0 comments on commit 6dad022

Please sign in to comment.