refac/enh: drop profile_image_url field in responses

This commit is contained in:
Timothy Jaeryang Baek 2025-11-26 21:47:20 -05:00
parent 3fe5a47050
commit 384753c6ca
4 changed files with 17 additions and 27 deletions

View file

@ -3,7 +3,7 @@ import uuid
from typing import Optional from typing import Optional
from open_webui.internal.db import Base, get_db from open_webui.internal.db import Base, get_db
from open_webui.models.users import UserModel, Users from open_webui.models.users import UserModel, UserProfileImageResponse, Users
from open_webui.env import SRC_LOG_LEVELS from open_webui.env import SRC_LOG_LEVELS
from pydantic import BaseModel from pydantic import BaseModel
from sqlalchemy import Boolean, Column, String, Text from sqlalchemy import Boolean, Column, String, Text
@ -46,15 +46,7 @@ class ApiKey(BaseModel):
api_key: Optional[str] = None api_key: Optional[str] = None
class UserResponse(BaseModel): class SigninResponse(Token, UserProfileImageResponse):
id: str
email: str
name: str
role: str
profile_image_url: str
class SigninResponse(Token, UserResponse):
pass pass

View file

@ -135,18 +135,18 @@ class UserIdNameListResponse(BaseModel):
total: int total: int
class UserResponse(BaseModel):
id: str
name: str
email: str
role: str
profile_image_url: str
class UserNameResponse(BaseModel): class UserNameResponse(BaseModel):
id: str id: str
name: str name: str
role: str role: str
class UserResponse(UserNameResponse):
email: str
class UserProfileImageResponse(UserNameResponse):
email: str
profile_image_url: str profile_image_url: str

View file

@ -16,9 +16,8 @@ from open_webui.models.auths import (
SigninResponse, SigninResponse,
SignupForm, SignupForm,
UpdatePasswordForm, UpdatePasswordForm,
UserResponse,
) )
from open_webui.models.users import Users, UpdateProfileForm from open_webui.models.users import UserProfileImageResponse, Users, UpdateProfileForm
from open_webui.models.groups import Groups from open_webui.models.groups import Groups
from open_webui.models.oauth_sessions import OAuthSessions from open_webui.models.oauth_sessions import OAuthSessions
@ -78,7 +77,7 @@ log.setLevel(SRC_LOG_LEVELS["MAIN"])
############################ ############################
class SessionUserResponse(Token, UserResponse): class SessionUserResponse(Token, UserProfileImageResponse):
expires_at: Optional[int] = None expires_at: Optional[int] = None
permissions: Optional[dict] = None permissions: Optional[dict] = None
@ -149,7 +148,7 @@ async def get_session_user(
############################ ############################
@router.post("/update/profile", response_model=UserResponse) @router.post("/update/profile", response_model=UserProfileImageResponse)
async def update_profile( async def update_profile(
form_data: UpdateProfileForm, session_user=Depends(get_verified_user) form_data: UpdateProfileForm, session_user=Depends(get_verified_user)
): ):

View file

@ -359,14 +359,14 @@ async def update_user_info_by_session_user(
############################ ############################
class UserResponse(BaseModel): class UserActiveResponse(BaseModel):
name: str name: str
profile_image_url: str profile_image_url: Optional[str] = None
active: Optional[bool] = None active: Optional[bool] = None
model_config = ConfigDict(extra="allow") model_config = ConfigDict(extra="allow")
@router.get("/{user_id}", response_model=UserResponse) @router.get("/{user_id}", response_model=UserActiveResponse)
async def get_user_by_id(user_id: str, user=Depends(get_verified_user)): async def get_user_by_id(user_id: str, user=Depends(get_verified_user)):
# Check if user_id is a shared chat # Check if user_id is a shared chat
# If it is, get the user_id from the chat # If it is, get the user_id from the chat
@ -384,11 +384,10 @@ async def get_user_by_id(user_id: str, user=Depends(get_verified_user)):
user = Users.get_user_by_id(user_id) user = Users.get_user_by_id(user_id)
if user: if user:
return UserResponse( return UserActiveResponse(
**{ **{
"id": user.id, "id": user.id,
"name": user.name, "name": user.name,
"profile_image_url": user.profile_image_url,
"active": get_active_status_by_user_id(user_id), "active": get_active_status_by_user_id(user_id),
} }
) )