def get_slack_user(user, slack_users):
    """Return user profile from Slack."""
    if hasattr(user, 'profile'):
        if user.profile.slack_api_id:
            for slack_user in slack_users:
                if slack_user['id'] == user.profile.slack_api_id:
                    return slack_user
        return None
    else:
        for slack_user in slack_users:
            if user.email and slack_user.get('profile', {}).get('email', None
                ) == user.email:
                return slack_user
        return None
