def parse_user_data(user):
    """Parse the user's information into a dictionary."""
    data = {
        "id": user.id,
        "email": user.email,
        "username": user.username,
        "active": user.active,
        "confirmed": user.confirmed_at is not None,
        "preferences": dict(user.preferences or {}),
        "profile": dict(user.user_profile or {}),
    }

    data["preferences"].setdefault("visibility", "restricted")
    data["preferences"].setdefault("email_visibility", "restricted")
    return data