diff --git a/backend/open_webui/models/groups.py b/backend/open_webui/models/groups.py index 5885226ce..9123606cd 100644 --- a/backend/open_webui/models/groups.py +++ b/backend/open_webui/models/groups.py @@ -85,7 +85,6 @@ class GroupForm(BaseModel): class GroupUpdateForm(GroupForm): user_ids: Optional[list[str]] = None - admin_ids: Optional[list[str]] = None class GroupTable: diff --git a/backend/open_webui/models/users.py b/backend/open_webui/models/users.py index 9ba127605..cc4793a8d 100644 --- a/backend/open_webui/models/users.py +++ b/backend/open_webui/models/users.py @@ -300,5 +300,10 @@ class UsersTable: except Exception: return None + def get_valid_user_ids(self, user_ids: list[str]) -> list[str]: + with get_db() as db: + users = db.query(User).filter(User.id.in_(user_ids)).all() + return [user.id for user in users] + Users = UsersTable() diff --git a/backend/open_webui/routers/groups.py b/backend/open_webui/routers/groups.py index e8f8994a4..5b5130f71 100644 --- a/backend/open_webui/routers/groups.py +++ b/backend/open_webui/routers/groups.py @@ -2,6 +2,8 @@ import os from pathlib import Path from typing import Optional + +from open_webui.models.users import Users from open_webui.models.groups import ( Groups, GroupForm, @@ -80,6 +82,9 @@ async def update_group_by_id( id: str, form_data: GroupUpdateForm, user=Depends(get_admin_user) ): try: + if form_data.user_ids: + form_data.user_ids = Users.get_valid_user_ids(form_data.user_ids) + group = Groups.update_group_by_id(id, form_data) if group: return group