enh: group members endpoint

This commit is contained in:
Timothy Jaeryang Baek
2025-12-02 11:24:23 -05:00
parent e301d1962e
commit 01868e856a
2 changed files with 29 additions and 1 deletions
+19 -1
View File
@@ -3,7 +3,7 @@ from pathlib import Path
from typing import Optional
import logging
from open_webui.models.users import Users
from open_webui.models.users import Users, UserInfoResponse
from open_webui.models.groups import (
Groups,
GroupForm,
@@ -118,6 +118,24 @@ async def export_group_by_id(id: str, user=Depends(get_admin_user)):
)
############################
# GetUsersInGroupById
############################
@router.post("/id/{id}/users", response_model=list[UserInfoResponse])
async def get_users_in_group(id: str, user=Depends(get_admin_user)):
try:
users = Users.get_users_by_group_id(id)
return users
except Exception as e:
log.exception(f"Error adding users to group {id}: {e}")
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=ERROR_MESSAGES.DEFAULT(e),
)
############################
# UpdateGroupById
############################