From 384753c6cae0dec972e477ec7d94fa4849f52321 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 26 Nov 2025 21:47:20 -0500 Subject: [PATCH] refac/enh: drop profile_image_url field in responses --- backend/open_webui/models/auths.py | 12 ++---------- backend/open_webui/models/users.py | 16 ++++++++-------- backend/open_webui/routers/auths.py | 7 +++---- backend/open_webui/routers/users.py | 9 ++++----- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/backend/open_webui/models/auths.py b/backend/open_webui/models/auths.py index 39ff1cc7fb..0d0b881a78 100644 --- a/backend/open_webui/models/auths.py +++ b/backend/open_webui/models/auths.py @@ -3,7 +3,7 @@ import uuid from typing import Optional 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 pydantic import BaseModel from sqlalchemy import Boolean, Column, String, Text @@ -46,15 +46,7 @@ class ApiKey(BaseModel): api_key: Optional[str] = None -class UserResponse(BaseModel): - id: str - email: str - name: str - role: str - profile_image_url: str - - -class SigninResponse(Token, UserResponse): +class SigninResponse(Token, UserProfileImageResponse): pass diff --git a/backend/open_webui/models/users.py b/backend/open_webui/models/users.py index d93f7ddeb3..5809a7124f 100644 --- a/backend/open_webui/models/users.py +++ b/backend/open_webui/models/users.py @@ -135,18 +135,18 @@ class UserIdNameListResponse(BaseModel): total: int -class UserResponse(BaseModel): - id: str - name: str - email: str - role: str - profile_image_url: str - - class UserNameResponse(BaseModel): id: str name: str role: str + + +class UserResponse(UserNameResponse): + email: str + + +class UserProfileImageResponse(UserNameResponse): + email: str profile_image_url: str diff --git a/backend/open_webui/routers/auths.py b/backend/open_webui/routers/auths.py index 764196c5f1..2a73496f3b 100644 --- a/backend/open_webui/routers/auths.py +++ b/backend/open_webui/routers/auths.py @@ -16,9 +16,8 @@ from open_webui.models.auths import ( SigninResponse, SignupForm, 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.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 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( form_data: UpdateProfileForm, session_user=Depends(get_verified_user) ): diff --git a/backend/open_webui/routers/users.py b/backend/open_webui/routers/users.py index f9e1c220a9..eddc56d77a 100644 --- a/backend/open_webui/routers/users.py +++ b/backend/open_webui/routers/users.py @@ -359,14 +359,14 @@ async def update_user_info_by_session_user( ############################ -class UserResponse(BaseModel): +class UserActiveResponse(BaseModel): name: str - profile_image_url: str + profile_image_url: Optional[str] = None active: Optional[bool] = None 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)): # Check if user_id is a shared 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) if user: - return UserResponse( + return UserActiveResponse( **{ "id": user.id, "name": user.name, - "profile_image_url": user.profile_image_url, "active": get_active_status_by_user_id(user_id), } )