This commit is contained in:
Timothy Jaeryang Baek committed 2026-05-11 02:15:46 +09:00
1 parent 2dbf7b6764
commit 3a21b334cc
1 file changed
+6 -12
+6 -12
View File
@@ -1412,6 +1412,9 @@ async def update_shared_chat_access_by_id(
user=Depends(get_verified_user), user=Depends(get_verified_user),
db: AsyncSession = Depends(get_async_session), db: AsyncSession = Depends(get_async_session),
): ):
if user.role == 'admin':
chat = await Chats.get_chat_by_id(id, db=db)
else:
chat = await Chats.get_chat_by_id_and_user_id(id, user.id, db=db) chat = await Chats.get_chat_by_id_and_user_id(id, user.id, db=db)
if not chat: if not chat:
raise HTTPException( raise HTTPException(
@@ -1419,12 +1422,6 @@ async def update_shared_chat_access_by_id(
detail=ERROR_MESSAGES.NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND,
) )
if chat.user_id != user.id and user.role != 'admin':
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
)
form_data.access_grants = await filter_allowed_access_grants( form_data.access_grants = await filter_allowed_access_grants(
request.app.state.config.USER_PERMISSIONS, request.app.state.config.USER_PERMISSIONS,
user.id, user.id,
@@ -1449,6 +1446,9 @@ async def get_shared_chat_access_by_id(
user=Depends(get_verified_user), user=Depends(get_verified_user),
db: AsyncSession = Depends(get_async_session), db: AsyncSession = Depends(get_async_session),
): ):
if user.role == 'admin':
chat = await Chats.get_chat_by_id(id, db=db)
else:
chat = await Chats.get_chat_by_id_and_user_id(id, user.id, db=db) chat = await Chats.get_chat_by_id_and_user_id(id, user.id, db=db)
if not chat: if not chat:
raise HTTPException( raise HTTPException(
@@ -1456,12 +1456,6 @@ async def get_shared_chat_access_by_id(
detail=ERROR_MESSAGES.NOT_FOUND, detail=ERROR_MESSAGES.NOT_FOUND,
) )
if chat.user_id != user.id and user.role != 'admin':
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
)
grants = await AccessGrants.get_grants_by_resource('shared_chat', id, db=db) grants = await AccessGrants.get_grants_by_resource('shared_chat', id, db=db)
return [ return [
{ {